Battle-tested smart contracts that successfully pass all Base Learn validations
🚀 Deploy • 📚 Contracts • 🏆 Rewards • 💡 Tips
Soulbound Tokens |
5 Achievement Tiers |
TalentProtocol |
After hours of debugging and testing, I've compiled working solutions for all 13 Base Learn exercises. Each contract has been:
- ✅ Deployed and verified on Base Sepolia
- ✅ Successfully minted the corresponding NFT
- ✅ Optimized for gas efficiency
- ✅ Documented for learning
💡 Note: These are meant for learning! Understand the code before deploying.
Click to see all 13 exercises with direct links
# | Exercise | Contract | Quest Link | Key Concepts |
---|---|---|---|---|
01 | Basic Math | BasicMath.sol |
🔗 Quest | Overflow-safe arithmetic, error handling |
02 | Control Structures | ControlStructures.sol |
🔗 Quest | FizzBuzz, time-based logic, custom errors |
03 | Storage | EmployeeStorage.sol |
🔗 Quest | Storage optimization, packing, memory vs storage |
04 | Arrays | FavoriteRecords.sol |
🔗 Quest | Dynamic arrays, array manipulation |
05 | Mappings | FavoriteRecords.sol |
🔗 Quest | Mapping operations, nested mappings |
06 | Inheritance | InheritanceContracts.sol |
🔗 Quest | Contract inheritance, virtual/override |
07 | Structs | GarageManager.sol |
🔗 Quest | Custom data structures, struct arrays |
08 | Error Triage | ErrorTriageExercise.sol |
🔗 Quest | Debugging, error patterns, assembly |
09 | New Keyword | AddressBookFactory.sol |
🔗 Quest | Factory pattern, contract deployment |
10 | Imports | ImportsExercise.sol |
🔗 Quest | Libraries, code reuse, using for |
11 | ERC-721 | HaikuNFT.sol |
🔗 Quest | NFT standard, OpenZeppelin, minting |
12 | Minimal Token | UnburnableToken.sol |
🔗 Quest | Basic token mechanics, transfers |
13 | ERC-20 | WeightedVoting.sol |
🔗 Quest | Governance token, voting mechanics |
# 1. Clone this repository
git clone https://github.com/YOUR_USERNAME/base-learn-solutions.git
cd base-learn-solutions
# 2. Install dependencies
npm install
# 3. Set up your environment
cp .env.example .env
PRIVATE_KEY=your_private_key_here
BASE_SEPOLIA_RPC=https://sepolia.base.org
BASESCAN_API_KEY=your_basescan_api_key
⚠️ Security: Never commit your.env
file!
Option 1: Deploy All Contracts
npx hardhat compile
npx hardhat run scripts/deploy-all.ts --network baseSepolia
Option 2: Deploy Individual Contracts
# Compile first
npx hardhat compile
# Then deploy specific contract
npx hardhat run scripts/deploy-01-basicmath.ts --network baseSepolia
graph LR
A[Deploy Contract] --> B[Copy Address]
B --> C[Visit Base Learn]
C --> D[Submit Address]
D --> E[Mint NFT! 🎉]
- Deploy your contract to Base Sepolia
- Copy the contract address from terminal
- Navigate to Base Learn
- Paste address and submit
- Mint your NFT!
Issue | Solution |
---|---|
"Unable to estimate gas" | Contract validation failed - check function signatures |
"Transaction underpriced" | Previous transaction pending - wait or increase gas |
Contract not verifying | Ensure exact function names and parameters match |
Imports failing | Deploy library contract first, then main contract |
- Batch Operations: Deploy 3-4 contracts at once
- Use Remix: For quick testing before Hardhat deployment
- Pre-fund Wallet: Have enough Base Sepolia ETH ready
- Keep Tab Open: Stay logged into Base Learn platform
- ✅ Use a dedicated testnet wallet
- ✅ Store keys in
.env
, never hardcode - ✅ Verify contracts on BaseScan after deployment
- ✅ Test locally with
npx hardhat test
first
Found a better solution? Contributions are welcome!
# 1. Fork the repository
# 2. Create your feature branch
git checkout -b feature/better-solution
# 3. Commit your changes
git commit -m '✨ Improve Exercise X solution'
# 4. Push and create PR
git push origin feature/better-solution
MIT License - Use freely to complete Base Learn!
Special thanks to:
Base Learn Team • OpenZeppelin • Hardhat • The Base Community
Made with ❤️ by JSONbored