A comprehensive Hardhat-based development environment for building and deploying smart contracts on Base blockchain, featuring a modern React frontend with Tailwind CSS and Web3 wallet integration.
This project is designed for learning and developing smart contracts with the following key features:
- Smart Contracts: Collection of educational Solidity contracts covering various concepts
- Hardhat Development Environment: Complete setup for compilation, testing, and deployment
- Base Blockchain Integration: Configured for Base mainnet and testnet deployments
- Modern Frontend: React application with Tailwind CSS and Web3 wallet connectivity
- Multi-Contract Support: Various contract types including ERC20, ERC721, and custom implementations
βββ contracts/ # Solidity smart contracts
β βββ 01_BasicMath.sol
β βββ 02_ControlStructures.sol
β βββ 03_EmployeeStorage.sol
β βββ 04_ArraysExercise.sol
β βββ 05_FavoriteRecords.sol
β βββ 06_GarageManager.sol
β βββ 07_Inheritance.sol
β βββ 08_ImportsExercise.sol
β βββ 09_ErrorTriageExercise.sol
β βββ 10_NewExercise.sol
β βββ 11_UnburnableToken.sol
β βββ 12_WeightedVoting.sol
β βββ 13_HaikuNFT.sol
β βββ utils/
βββ deploy/ # Deployment scripts
β βββ deploy.js
β βββ erc20/
β βββ erc721/
β βββ perc20/
β βββ private-nft/
β βββ proxy/
βββ frontend/ # React frontend application
β βββ src/
β βββ public/
β βββ package.json
βββ test/ # Test files
βββ artifacts/ # Compiled contracts
βββ typechain-types/ # TypeScript type definitions
- Node.js (v16 or higher)
- npm or yarn
- MetaMask or compatible Web3 wallet
- Base network access (testnet/mainnet)
# Install main project dependencies
npm install --force
# Install frontend dependencies
cd frontend
npm installCreate a .env file in the root directory:
# Copy from example
cp env_example .envEdit .env file with your configuration:
# Private key for deployment (use testnet account)
PRIVATE_KEY=your_private_key_hereThe project is pre-configured for Base blockchain in hardhat.config.ts:
- Base Mainnet: Chain ID 8453
- Base Goerli Testnet: Chain ID 84531
- Base Sepolia Testnet: Chain ID 84532
# Compile contracts
npx hardhat compile
# Run tests
npx hardhat test
# Deploy to Base testnet
npx hardhat run --network baseSepolia deploy/deploy.js
# Deploy to Base mainnet
npx hardhat run --network base deploy/deploy.js
# Verify contract (requires BASESCAN_API_KEY)
npx hardhat verify --network base CONTRACT_ADDRESS
# Start local Hardhat node
npx hardhat node# Navigate to frontend directory
cd frontend
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview- BasicMath: Mathematical operations and basic Solidity syntax
- ControlStructures: If/else statements, loops, and control flow
- EmployeeStorage: Struct usage and state management
- ArraysExercise: Dynamic arrays and array manipulation
- FavoriteRecords: Mapping usage and data structures
- GarageManager: Complex state management example
- Inheritance: Contract inheritance patterns
- ImportsExercise: Modular contract development
- ErrorTriageExercise: Error handling and custom errors
- UnburnableToken: ERC20 token implementation
- HaikuNFT: ERC721 NFT contract
- WeightedVoting: Governance token with voting mechanism
The React frontend includes:
- Wallet Connection: MetaMask and WalletConnect integration via RainbowKit
- Contract Interaction: Read and write operations with smart contracts
- Tailwind CSS: Modern, responsive UI components
- Web3 Integration: ethers.js and wagmi for blockchain interactions
- React 19: Latest React with concurrent features
- Tailwind CSS v4: Utility-first CSS framework
- Vite: Fast build tool and development server
- ethers.js: Ethereum library for blockchain interaction
- wagmi: React hooks for Ethereum
- RainbowKit: Wallet connection UI
# Deploy specific contract type
npx hardhat run --network base deploy/erc20/deploy.js
npx hardhat run --network base deploy/erc721/deploy-erc721.js
npx hardhat run --network base deploy/proxy/deploy.ts# Deploy and verify in one command
npx hardhat run --network base deploy/deploy.js && \
npx hardhat verify --network base <CONTRACT_ADDRESS>Run the complete test suite:
# Run all tests
npx hardhat test
# Run specific test file
npx hardhat test test/Lock.ts
# Run tests with gas reporting
REPORT_GAS=true npx hardhat test
# Run tests with coverage
npx hardhat coverage- Private Keys: Never commit private keys to version control
- Test Networks: Always test on testnets before mainnet deployment
- Contract Verification: Verify all contracts on Basescan
- Audit: Consider professional audits for production contracts
- Access Control: Implement proper access controls in contracts
- Basic syntax and data types
- Control structures and functions
- Structs, arrays, and mappings
- Contract inheritance
- Error handling
- ERC20/ERC721 token standards
- Upgradeable contracts with proxies
- Start with
01_BasicMath.solfor Solidity basics - Progress through numbered contracts in order
- Experiment with frontend integration
- Deploy to testnet and interact via UI
- Explore advanced patterns in proxy contracts
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Contract compilation fails:
npx hardhat clean
npx hardhat compileFrontend won't start:
cd frontend
rm -rf node_modules package-lock.json
npm installDeployment fails:
- Check your private key format (with 0x prefix)
- Ensure sufficient ETH balance for gas fees
- Verify network configuration in hardhat.config.ts
Tailwind CSS not working:
- Ensure
@import "tailwindcss";is in index.css - Check that
@tailwindcss/viteplugin is in vite.config.js
For questions and support:
- Check existing issues in the repository
- Create a new issue with detailed description
- Include error messages and system information
Happy coding! π
