Skip to content

Week 1: Foundations & First Contract

Time estimate: ~8-10 hours (including homework) | Difficulty: Beginner | Prerequisites: Basic Solidity knowledge


What You'll Learn

This week takes you from zero FHE knowledge to writing and testing your first encrypted smart contract. You'll understand:

  • What Fully Homomorphic Encryption (FHE) is and why it matters for blockchain privacy
  • How the FHEVM coprocessor architecture works under the hood
  • The encrypted data lifecycle: encrypt → compute → authorize → decrypt
  • How to set up a Hardhat development environment for FHEVM
  • How mock mode enables fast, deterministic local testing
  • How to write, test, and reason about encrypted smart contracts

What You'll Build

FHECounter.sol — An encrypted counter contract where the count value is always encrypted on-chain and only authorized users can decrypt it off-chain.

Encrypt input → Verify → Compute on ciphertext → Authorize → Decrypt off-chain

Weekly Milestones

  • [ ] Lesson 1 — Understand FHE theory, encrypted types, the coprocessor model, and the ACL
  • [ ] Lesson 2 — Install Node.js, clone the repo, run npm run compile and npm test
  • [ ] Lesson 3 — Walk through FHECounter.sol, understand the encrypted test loop, and complete the multiply exercise
  • [ ] Homework — Build EncryptedPoll.sol from the starter template and pass the provided tests

Lessons

Lesson 1: FHE Theory ~45 min

Learn what FHE is, how it compares to other privacy approaches, and how the FHEVM coprocessor model makes encrypted computation feel like Solidity.

Lesson 2: Environment Setup ~30 min

Install the Hardhat toolchain, clone the bootcamp repo, understand the project structure, and run the encrypted test flow locally in mock mode.

Lesson 3: Hello FHE — Your First Encrypted Contract ~60 min

Walk through FHECounter.sol line by line, understand every FHE operation, and learn the core encrypt → call → decrypt loop.

Homework: EncryptedPoll ~4-5 hours

Build an encrypted voting contract from scratch using the starter template and the week 1 Hardhat test suite.


Key Concepts This Week

ConceptDescription
FHEComputation on encrypted data without decrypting
CoprocessorOff-chain FHE executor used by the Solidity library
euint32Encrypted unsigned 32-bit integer
externalEuint32Encrypted user input before contract-side verification
FHE.fromExternal()Verify and convert an external encrypted input
FHE.add() / FHE.sub()Encrypted arithmetic operations
FHE.allowThis()Grant contract permission to reuse an encrypted handle
FHE.allow()Grant a user permission to decrypt a handle
Mock modeLocal testing with the Hardhat FHEVM mock runtime

Ready? Start with Lesson 1: FHE Theory.

Built for the Zama Developer Program — Bounty Track