Have you found yourself Foundry-pilled but don't know where to start? This repo showcases many of the benefits Foundry could bring to your project! The main benefit being one single language for everything related to smart contracts. Everything in this repo is written in Solidity: contracts & tests!
Please read the readme's in the src and test folders for more information about the source contracts and the tests.
Installing and configuring Foundry is lightning fast.
Please install the following:
- Foundry / Foundryup
- Install
foundryup
with the following command or check the official docs curl -L https://foundry.paradigm.xyz | bash
- To install or update the Foundry components simply run
foundryup
- This will install
forge
,cast
, andanvil
- Install
Foundry works out of the box! But if you need any custom logic, the configuration lives in foundry.toml
.
When adding Foundry to an existing project, you might want to remap the testing and the src folders.
In this repo we've kept the custom configuration to a minimum, only specifying the optimizer_runs
value and adding some CI and fmt
config.
For more configuration options check the docs.
Foundry comes with many features and is still under very active development.
For now, this repository will mainly focus on Forge, the testing component of Foundry.
Besides Forge there is Cast
, a command-line tool for performing Ethereum RPC calls and Anvil
, a local testnet node.
Forge offers a suite of functionality and QoL improvements for Solidity developers.
Some of the features we're using are tests test
, the formatter fmt
, the gas snapshot snapshot
and coverage coverage
.
For more information on Forge subcommands read the official docs.
The following CLI command will be used very frequently.
forge test
or test a specific contract with
forge test --match-contract CONTRACT_NAME
forge fmt
forge snapshot
Cast is Foundry's command-line tool for performing Ethereum RPC calls. You can make smart contract calls, send transactions, or retrieve any type of chain data - all from your command-line!
Anvil is a local testnet node shipped with Foundry. You can use it for testing your contracts from frontends or for interacting over RPC.
We've automated building, testing, gas snapshots and formatting in our CI pipeline. PRs can only be merged when all tests are green, the gas-snapshot is up-to-date and the formatting is correct. This ensures only high quality code reaches the main branch.
Contributions are always welcome!