Introducing solidity-template, a Solidity template for Ethereum smart contracts. It optimally combines two extremely powerful frameworks:
Most contract repositories out there in the wild choose either one or the other. Both offer powerful tools for contract development, and although there is some overlap in their functionality, there is a multitude of reasons that you should be utilizing both:
-
Complete test coverage using Forge to cover the raw contract logic and basic scenarios, and Hardhat the complex user interactions.
-
Maximum suite of tools for contract debugging, deployment, gas measurements, etc.
-
Reference for on-chain developers writing contracts that call these contracts in your Unit Test files to see the expected usage in Solidity.
-
Reference for off-chain developers writing clients that call these contracts in your Integration Test files to see the expected usage in JavaScript (TypeScript) and Ethers.js.
The latter case has already proven to be extremely useful for a new project Git Consensus, where just pushing integration test code gave examples for the frontend devs concurrently to know how they need to prepare input parameters for the contract functions. This will only be more relevant as the community shifts to patterns that encourage loaded input parameters for gas savings.
Of the repositories that do combine try to combine both Foundry and Hardhat, none are optimized together in a way that makes them convenient to develop in. This is due to the split between how Foundry handles dependencies (git submodules located in /lib
) and Hardhat handles dependencies (managed with NPM). Nothing felt up-to-date with contract development best practices in 2022.
This gap in a fully-featured, modern Solidity template that utilizes both frameworks inspired me to publish solidity-template – not only is it optimized for using both, but it also offers a lot of the boilerplate a project will be able to utilize to streamline development: GitHub Actions, interactive CLI, linting, doc generation, deployment address tracking, contributor guides, etc.
This template includes an easy-to-follow example Counter.sol, with its interface ICounter.sol, Unit Test file Counter.t.sol, and Integration Test file counter.test.ts.
If you like it, definitely give it a ⭐ so you can remember to use it for your next project!