Documentation Index
Fetch the complete documentation index at: https://mintlify.com/0xchriswilder/journey/llms.txt
Use this file to discover all available pages before exploring further.
Week 4: Production & Capstone
Subtitle: Advanced patterns, production deployment, and capstone project Estimated Time: 15 hours of lessons + 15 hours capstone projectObjectives
Advanced Patterns
Production Contracts
Security & Deployment
Capstone Project
Milestone
Lessons
Lesson 4.1: Advanced FHEVM Applications
Duration: 60 minutesLearning Objectives
Learning Objectives
- Design a sealed-bid auction contract with encrypted bids
- Implement private ERC-20 token transfers with encrypted balances
- Architect a confidential DAO voting system with weighted votes
Sealed-Bid Auction (BlindAuction)
Sealed-Bid Auction (BlindAuction)
highestBid starts uninitialized — use FHE.isInitialized() to checkFHE.select() updates highest bid without revealing either valueFHE.select() (new ciphertext)makePubliclyDecryptable → checkSignaturesERC7984 Confidential Token (OpenZeppelin)
ERC7984 Confidential Token (OpenZeppelin)
euint64, transfers use encrypted amounts with proof verification, and only account holders can decrypt their own balance.euint64 — chain never stores plaintextFHE.fromExternal() converts client-side encryption to on-chain format_update() hook runs on every mint/burn/transfer for ACL managementLesson 4.2: Contract Deep Dive & Gas Optimization
Duration: 60 minutesLearning Objectives
Learning Objectives
- Understand why sealed-bid auctions solve front-running and shill bidding
- Trace the three-phase state machine and key FHE operations
- See why incremental winner tracking is used instead of batch comparison
- Apply gas optimization strategies: type selection, batching, minimal decryption
Why Sealed-Bid Auctions?
Why Sealed-Bid Auctions?
FHE.gt() comparison without revealing valuesThe Three-Phase State Machine
The Three-Phase State Machine
FHE.gt() + FHE.select() without revealing any value.Phase 2: ClosedBidding ends. The auctioneer receives permission to decrypt the winner (FHE.allow or makePubliclyDecryptable).Phase 3: RevealedThe auctioneer publishes winner and winning bid on-chain after proof verification.Key FHE Operations
Key FHE Operations
ebool — “is this bid higher?” — without revealing either number.FHE.select(isHigher, bid, highestBid)Picks the new highest bid based on the encrypted condition. No information leaked.FHE.isInitialized(highestBid)Used to handle the first bid: no comparison needed until there is a previous highest.The New-Handle RuleAfter any FHE operation that creates a new handle (e.g., FHE.select), you must call FHE.allowThis() again on the new handle.Why Incremental Tracking?
Why Incremental Tracking?
placeBid instead of comparing all bids when the auction closes?Answer 1: Gas DistributionFHE comparisons are expensive. Incremental approach spreads cost across all placeBid transactions instead of one huge closeAuction.Answer 2: ScalabilityWith many bidders, a batch comparison could exceed block gas limit. Each placeBid does O(1) FHE work.Gas Optimization Strategies
Gas Optimization Strategies
euint8 operations are cheaper than euint64. Only use larger types when needed.2. Minimize Decryption RequestsEach decryption has overhead. Batch multiple values into a single request.3. Batch OperationsCombine multiple operations to reduce the number of FHE calls.4. Avoid Unnecessary PermissionsOnly call FHE.allowThis() and FHE.allow() when you need decryption access.5. Cache ConstantsIf you use FHE.asEuint8(0) or FHE.asEuint8(1) frequently, cache them in state.Lesson 4.3: Production Deployment & Security
Duration: 45 minutesLearning Objectives
Learning Objectives
- Complete a security checklist for FHEVM contracts
- Deploy to production (mainnet) with proper configuration
- Set up monitoring and alerting for deployed contracts
- Identify next steps and advanced resources for continued learning
FHEVM Security Checklist
FHEVM Security Checklist
Access Control
onlyOwner, role-based, etc.)Permission Management
FHE.allowThis() and FHE.allow() call. Ensure no unauthorized addresses can decrypt.Input Validation
FHE.fromExternal() with proof verification. Never accept raw encrypted data without proof.State Consistency
Proof Verification
FHE.checkSignatures() before using decrypted values.Gas Limits
Next Steps & Resources
Next Steps & Resources
- zama-ai/fhevm-hardhat-template — Official Hardhat template
- 0xchriswilder/fhevm-react-template — Universal FHEVM SDK
Capstone Project
Estimated Time: 15 hours Objective: Build a production-quality confidential dApp demonstrating end-to-end FHEVM proficiency.Choose Your Track
Track A: DeFi
- Multiple simultaneous auctions
- Bid deposit/refund system
- Minimum bid threshold
- Creator fee on winning bid
Track B: Governance
- Token holders vote with encrypted weight
- Multiple proposals active simultaneously
- Quorum threshold (minimum total weight)
- Delegation:
allow(votingPower, delegateAddress)
Track C: Identity
- Users store encrypted attributes
- Prove attribute ranges without revealing values
- Selective disclosure to verifiers
- Credential revocation
Requirements
1. Smart Contract (25%)
1. Smart Contract (25%)
2. Frontend Application (25%)
2. Frontend Application (25%)
3. Test Suite (15%)
3. Test Suite (15%)
4. Documentation (15%)
4. Documentation (15%)
- Project overview
- Architecture diagram
- Setup instructions
- Usage guide
- Security considerations
5. Concept & Design (20%)
5. Concept & Design (20%)
- Clear concept with privacy rationale
- Sound architecture
- Appropriate use of FHEVM patterns
Grading Criteria
| Criterion | Weight | Excellence (90-100%) |
|---|---|---|
| Concept & Design | 20% | Novel concept, excellent architecture, clear privacy rationale |
| Smart Contract | 25% | Production-quality, proper permissions, gas-optimized |
| Frontend | 25% | Polished, responsive UI with excellent UX and error handling |
| Testing | 15% | >90% coverage, tests for edge cases and failure modes |
| Documentation | 15% | Comprehensive README with diagrams, GIFs, clear instructions |