- Fast
- Built-in fuzzing
- Solidity based testing
- EVM Cheat codes
- Script based in shell / bash
- https://github.com/PatrickAlphaC/foundry-play
- https://github.com/smartcontractkit/foundry-starter-kit
Run :
curl -L https://foundry.paradigm.xyz | bash
Then :
foundryup
forge init --force
forge build
First, install the dependency :
forge install GithubOrg/GithubRepo
Then, add the dependency to foundry.toml
in the remappings tag
For example, to install Openzepplin contracts repository :
CLI :
forge install OpenZeppelin/openzeppelin-contracts
foundry.toml :
remappings = ['@openzeppelin/=lib/openzeppelin-contracts/']
To execute test cases, run :
forge test --fork-url <RPC_URL> -vvv
To analyze test coverage, run :
forge coverage --fork-url <RPC_URL>
Using CLI directly :
forge create --rpc-url <your_rpc_url> --private-key <your_private_key> src/MyContract.sol:MyContract
Using Forge Scripts :
forge script script/Contract.s.sol:Contract --rpc-url $OPTIMISM_GOERLI_RPC --broadcast --verify --etherscan-api-key ${OPTIMISM_ETHERSCAN_API_KEY}
To start a local testnet to test against, run :
anvil
See anvil configuration :
anvil -h