A comprehensive Solidity development template that combines Foundry and Hardhat for optimal smart contract development experience.
- Dual Testing Framework: Foundry for fast unit tests and Hardhat for integration tests
- Modern Tooling: Latest versions of Foundry, Hardhat, and OpenZeppelin contracts
- Code Quality: Pre-configured formatting, linting, and pre-commit hooks
- Multi-Network Support: Ready-to-use configurations for multiple testnets
- Deployment Ready: Automated deployment scripts with hardhat-sol-bundler
- Gas Optimization: Built-in gas reporting and optimization settings
- Git
- You'll know you've done it right if you can run
git --version
- You'll know you've done it right if you can run
- Node.js (v18 or higher)
- Foundry / Foundryup for unit testing and development
- Hardhat for integration tests & deployment
- Optional: Docker for containerized development
- Clone and install dependencies:
git clone https://github.com/dgma/sol-starter.git
cd sol-starter
npm install
npx husky install- Install Foundry dependencies:
forge install foundry-rs/forge-std- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration- Run tests:
# Unit tests with Foundry
forge test -vvv
# Integration tests with Hardhat
npm run int
# All tests
npm run testnpm run compile- Compile contracts with Hardhatnpm run format- Format Solidity code with Forgenpm run lint- Lint Solidity code with Solhintnpm run gas- Generate gas report
npm run test- Run all tests (Foundry + Hardhat)npm run unit:all- Run all Foundry unit testsnpm run int- Run Hardhat integration tests
npm run deploy- Deploy to specified networknpm run deploy:hh- Deploy to Hardhat networknpm run deploy:localhost- Deploy to localhostnpm run deploy:t- Deploy to Optimism Sepolia
npm run clean- Clean all build artifacts and dependencies
sol-starter/
├── src/ # Smart contract source files
├── test/ # Foundry unit tests
├── integration/ # Hardhat integration tests
├── lib/ # Foundry dependencies
├── artifacts/ # Hardhat compilation artifacts
├── cache/ # Foundry cache
├── foundry.toml # Foundry configuration
├── hardhat.config.js # Hardhat configuration
└── deployment.config.js # Deployment configuration
For the best development experience, use the Juan Blanco Solidity Plugin with these settings:
{
"solidity.formatter": "forge",
"solidity.packageDefaultDependenciesContractsDirectory": "src",
"solidity.packageDefaultDependenciesDirectory": ["node_modules", "lib"],
"solidity.remappings": [
"@std=lib/forge-std/src/",
"forge-std/=lib/forge-std/src/",
"@openzeppelin/=node_modules/@openzeppelin/",
"src=src/"
],
"solidity.defaultCompiler": "localNodeModule",
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
}
}Create a .env file with the following variables:
# Private key for deployment (without 0x prefix)
PRIVATE_KEY=your_private_key_here
# RPC URLs
SEPOLIA_RPC=https://sepolia.infura.io/v3/your_project_id
ARBITRUM_SEPOLIA_RPC=https://sepolia-rollup.arbitrum.io/rpc
OP_SEPOLIA_RPC=https://sepolia.optimism.io
# API Keys for verification
ETHERSCAN_API_KEY=your_etherscan_api_key
ARBISCAN_API_KEY=your_arbiscan_api_key
OPSCAN_API_KEY=your_opscan_api_key- Local Development: Hardhat, Localhost
- Testnets: Sepolia, Arbitrum Sepolia, Optimism Sepolia
- Mainnets: Configurable via hardhat.config.js
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Foundry Documentation
- Hardhat Documentation
- hardhat-sol-bundler Documentation
- OpenZeppelin Contracts
- Solidity Documentation
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Open an issue
- Check the documentation
- Join our community discussions
Note: This is a development template. Always audit your smart contracts before deploying to production networks.