This document contains exercises for Modules 2-6. For Module 1 exercises, see module-1-exercises.md.
Objective: Write and deploy a basic contract
Task: Create a SimpleStorage contract that:
- Stores a uint256 value
- Has a function to set the value
- Has a function to get the value
- Emits an event when value changes
Objective: Implement owner-only functions
Task: Create a contract with:
- Owner address stored
- OnlyOwner modifier
- Function to transfer ownership
- Owner-only administrative function
Objective: Use mappings and arrays
Task: Build a NameRegistry that:
- Maps addresses to names
- Stores all registered addresses in an array
- Allows users to register their name
- Prevents duplicate names
Objective: Implement a token contract
Task: Create a complete ERC-20 token with:
- Fixed supply
- Transfer functionality
- Approve/transferFrom pattern
- Events for all transfers
- Comprehensive tests
Objective: Coordinate multiple approvals
Task: Build a wallet that:
- Requires M of N signatures
- Allows proposal submission
- Tracks approvals
- Executes when threshold met
- Handles ETH and tokens
Objective: Implement proxy pattern
Task: Create an upgradeable contract using:
- Transparent proxy pattern
- Separate storage and logic
- Upgrade function
- Tests for upgrade process
Objective: Build a lending protocol
Task: Create a simple lending system:
- Users can deposit collateral
- Users can borrow against collateral
- Interest accumulates over time
- Liquidation mechanism
- Price oracle integration (mock)
Objective: Optimize contract gas usage
Task: Take a provided contract and:
- Reduce deployment gas by 30%
- Optimize common function gas usage
- Use appropriate data types
- Batch operations where possible
- Document all optimizations
Objective: Find and fix vulnerabilities
Task: Audit a provided vulnerable contract:
- Identify all security issues
- Categorize by severity
- Write exploit tests
- Fix all issues
- Write remediation tests
Objective: Implement NFT standard
Task: Create an ERC-721 contract with:
- Minting functionality
- Transfer capability
- Token URI for metadata
- Enumeration support
- Complete tests
Objective: Design NFT metadata
Task: Create metadata for an NFT collection:
- 10 unique JSON files
- Proper OpenSea format
- Image URLs (can be placeholders)
- Attributes and traits
- Upload to IPFS
Objective: Control NFT distribution
Task: Add to your ERC-721:
- Public mint function with price
- Mint limit per wallet
- Max supply cap
- Withdrawal function for owner
Objective: Implement Merkle tree whitelist
Task: Create a minting system with:
- Merkle tree generation script
- Merkle proof verification on-chain
- Whitelist and public mint phases
- Different prices for each phase
Objective: Create programmatic art
Task: Build a system that:
- Generates 100 unique NFT traits
- Combines traits into metadata
- Calculates rarity scores
- Creates complete metadata files
- Can be minted from contract
Objective: Multi-token standard
Task: Create an ERC-1155 contract for:
- Game items (fungible and non-fungible)
- Batch minting capability
- URI per token type
- Trading functionality
Objective: NFTs that change over time
Task: Build NFTs that:
- Track owner interaction
- Level up based on criteria
- Change metadata dynamically
- Emit events for trait changes
- Generate SVG on-chain based on state
Objective: Trading platform
Task: Create a marketplace with:
- List NFTs for sale
- Buy functionality
- Royalty distribution (ERC-2981)
- Offer system
- Events for all actions
Objective: Divide NFT ownership
Task: Implement fractionalization:
- Lock NFT in vault contract
- Issue ERC-20 shares
- Voting mechanism for NFT decisions
- Buyout mechanism
- Reclaim NFT when shares burned
Objective: Enhanced token contract
Task: Create an ERC-20 with:
- Burnable tokens
- Pausable transfers
- Mintable by owner
- Supply cap
- Comprehensive tests
Objective: Time-locked token distribution
Task: Build a vesting contract:
- Linear vesting over time
- Cliff period
- Revocable by owner
- Multiple beneficiaries
- Claim function
Objective: Plan token allocation
Task: Design distribution for a token:
- Create allocation spreadsheet
- Justify each allocation
- Plan vesting schedules
- Calculate emission over 5 years
- Visualize distribution
Objective: Stake tokens earn rewards
Task: Implement staking with:
- Deposit tokens
- Earn rewards over time
- Compound interest calculation
- Withdraw with rewards
- Lock periods with multipliers
Objective: DAO voting system
Task: Create governance with:
- Token-weighted voting
- Proposal creation
- Voting period
- Execution if passed
- Delegation support
Objective: Simulate token economy
Task: Build a spreadsheet model:
- Supply and demand projections
- Inflation/deflation mechanisms
- User growth scenarios
- Token price sensitivity
- Sustainability analysis
Objective: Automated pricing
Task: Implement bonding curve:
- Price increases with supply
- Buy and sell functions
- Bancor formula implementation
- Liquidity reserve management
- Slippage protection
Objective: Incentivize liquidity
Task: Build liquidity mining:
- LP token staking
- Reward distribution per block
- Multiple pools with weights
- Boost mechanisms
- Analytics dashboard
Objective: Model token launch
Task: Simulate a token launch:
- Fair launch mechanism
- Anti-bot measures
- Initial liquidity provision
- Price discovery period
- Early holder incentives
Objective: Recognize common vulnerabilities
Task: Review 5 vulnerable contracts and identify:
- Reentrancy issues
- Access control problems
- Integer overflow/underflow
- Unchecked external calls
- Front-running vulnerabilities
Objective: Fix security issues
Task: Take an insecure contract and:
- Fix all identified issues
- Add security checks
- Implement best practices
- Write security tests
- Document changes
Objective: Prevent reentrancy attacks
Task: Implement reentrancy protection:
- Create ReentrancyGuard
- Apply to vulnerable function
- Write exploit test (that fails)
- Verify protection works
- Document pattern
Objective: Hands-on security practice
Task: Complete all Ethernaut levels:
- Document each solution
- Explain the vulnerability
- Describe the fix
- Share learnings
Objective: DeFi-specific security
Task: Solve all challenges:
- Understand each protocol
- Find the exploit
- Write exploit code
- Propose fixes
- Document vulnerabilities
Objective: Prevent front-running
Task: Implement commit-reveal for:
- Sealed bid auction
- Voting system
- Random number generation
- Test all edge cases
Objective: Professional audit
Task: Audit a medium-complexity DeFi protocol:
- Complete security review
- Use automated tools (Slither, Mythril)
- Manual code review
- Write professional report
- Severity classification
Objective: Privacy-preserving verification
Task: Implement zk-SNARK with Circom:
- Prove you're over 18 without revealing age
- Create circuit
- Generate proof
- Verify on-chain
- Document process
Objective: Anonymous on-chain voting
Task: Build voting system with:
- Hidden votes during voting period
- Reveal phase after voting
- Verifiable results
- Anonymous voter identity
- Prevent double voting
Objective: Automated testing and deployment
Task: Create GitHub Actions workflow:
- Run tests on every commit
- Lint Solidity code
- Generate coverage report
- Deploy to testnet on merge
- Send notifications
Objective: Automated contract deployment
Task: Write Hardhat deploy scripts:
- Multi-network support
- Contract verification
- Save deployment addresses
- Idempotent deployments
- Rollback capability
Objective: Handle multiple environments
Task: Setup environments for:
- Local development
- Testnet staging
- Mainnet production
- Different RPC providers
- Secret management
Objective: Track contract activity
Task: Build monitoring for:
- Contract events
- Transaction volume
- Gas usage
- Error rates
- Alert on anomalies
Objective: Comprehensive test coverage
Task: Implement testing with:
- Unit tests (>90% coverage)
- Integration tests
- Forking mainnet tests
- Gas reporting
- Mutation testing
Objective: Automated code review
Task: Create AI-powered review:
- Analyze Solidity code
- Identify potential issues
- Suggest optimizations
- Generate review comments
- Compare with human review
Objective: Deploy to multiple networks
Task: Deploy same contracts to:
- Ethereum
- Polygon
- Optimism
- Arbitrum
- Automate verification on all
Objective: Handle emergencies
Task: Build incident response:
- Monitoring and alerting
- Automated pause mechanism
- Notification system
- Runbook documentation
- Post-mortem template
Objective: Optimize full stack
Task: Optimize application:
- Frontend load time <2s
- Contract gas optimization
- API response time <100ms
- Database query optimization
- Caching strategy
Combine all modules to build a complete application with:
- Smart contracts (Modules 2-4)
- Security measures (Module 5)
- AI features (Module 1)
- DevOps pipeline (Module 6)
Build an NFT platform emphasizing security:
- Audited contracts (Module 5)
- NFT functionality (Module 3)
- Governance (Module 4)
- Automated security scanning (Module 6)
Create a token system with AI:
- Token contract (Module 4)
- AI-powered analytics (Module 1)
- Security audited (Module 5)
- Full DevOps (Module 6)
- ✅ Complete all foundation exercises
- ✅ Complete 70% of intermediate exercises
- ✅ Attempt 50% of advanced exercises
- ✅ Build one integration project
- ✅ Document your learnings
- ✅ Get peer reviews
- ✅ Revise based on feedback
- Commit code regularly
- Write tests for everything
- Document as you build
- Ask for help when stuck
- Review others' solutions
- Iterate and improve
Good luck with all your exercises! 🚀