Highly opinionated template for smart contract development.
Combines hardhat and foundry testing frameworks to take advantage of coverage and fuzzing capabiltiies, along with their native tools.
The following will need to be installed. Please follow the links and instructions.
- Foundry
- Node >= 14
- yarn or npm >= 7
- Install dependencies
Once you've cloned and entered into your repository, you need to install the necessary dependencies. In order to do so, simply run:
yarn install
forge install
- Build
forge build
- Test
forge test -vvv
# or
npx hardhat test
For more information on how to use Foundry, check out the Foundry Github Repository or type forge help
in your terminal.
The template comes with a list of templates:
-
- Lint
- Test
- Coverage
- Show coverage report in the workflow summary
- Set
secrets.CODECOV_TOKEN
on GitHub for visualizing coverage report to codecov.io (NOTE: the secrets is not required for public repo)
-
- To enable the upload of the SARIF file to GitHub, Requires to be public repo or GitHub Enterprise Cloud user.
- Install libraries with Foundry which work with Hardhat.
forge install openzeppelin/openzeppelin-contracts # just an example
And then update remappings in foundry.toml
.
remappings = [
"@openzeppelin/=lib/openzeppelin-contracts/",
]
This will allow you to import libraries like this:
// Instead of import "lib/openzeppelin-contracts/token/ERC20/ERC20.sol";
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
- Generates and builds an mdbook from Solidity source files.
forge doc # generates docs in ./docs
forge doc --serve # generates docs and serves them on localhost:3000
forge snapshot
forge coverage
- Use Hardhat's task framework
npx hardhat example
- Use
cast
command which is a swiss army knife for smart contract development. Typecast --help
for more information.
Runs a published transaction in a local environment and prints the trace.
cast run <txhash> --rpc-url <rpc-url>
See deployment
For more infomation on how to use Foundry features, refer to: