https://github.com/foundry-rs/foundry
- Install
curl -L https://foundry.paradigm.xyz | bash
foundryup
- Init
forge init
- Basic commands
forge build
forge test
forge test --match-path test/HelloWorld -vvvv
- Test
- counter app
- test setup, ok, fail
- match
- verbose
- gas report
forge test --match-path test/Counter.t.sol -vvv --gas-report
- Solidity version and optimizer settings
https://github.com/foundry-rs/foundry/tree/master/config
- Remapping
forge remappings
forge install rari-capital/solmate
forge update lib/solmate
forge remove solmate
npm i @openzeppelin/contracts
- Formatter
forge fmt
- console (Counter, test, log int)
forge test --match-path test/Console.t.sol -vv
- Test auth
- Test error
vm.expectRevert
require
error message- custom error
- label assertions
- Test event (expectEmit)
- Test time (
Auction.sol
) - Test send eth (
Wallet.sol
) - hoax, deal - Test signature
- mainnet fork
forge test --fork-url $FORK_URL --match-path test/Fork.t.sol -vvv
- main fork deal (whale)
forge test --fork-url $FORK_URL --match-path test/Whale.t.sol -vvv
TODO: need working example for (mainnet - opt)
-
crosschain fork
-
Fuzzing (assume, bound)
forge test --match-path test/Fuzz.t.sol
- Invariant
# Open testing
forge test --match-path test/invariants/Invariant_0.t.sol -vvv
forge test --match-path test/invariants/Invariant_1.t.sol -vvv
# Handler
forge test --match-path test/invariants/Invariant_2.t.sol -vvv
# Actor management
forge test --match-path test/invariants/Invariant_3.t.sol -vvv
- FFI
forge test --match-path test/FFI.t.sol --ffi -vvv
- Differential testing
# virtual env
python3 -m pip install --user virtualenv
virtualenv -p python3 venv
source venv/bin/activate
pip install eth-abi
FOUNDRY_FUZZ_RUNS=100 forge test --match-path test/DifferentialTest.t.sol --ffi -vvv
- Vyper
https://github.com/0xKitsune/Foundry-Vyper
- Install vyper
# virtual env
python3 -m pip install --user virtualenv
virtualenv -p python3 venv
source venv/bin/activate
pip3 install vyper==0.3.7
# Check installation
vyper --version
- Put Vyper contract inside
vyper_contracts
- Declare Solidity interface inside
src
- Copy & paste
lib/utils/VyperDeployer.sol
- Write test
forge test --match-path test/Vyper.t.sol --ffi
- ignore error code
ignored_error_codes = ["license", "unused-param", "unused-var"]
- Deploy
source .env
forge script script/Token.s.sol:TokenScript --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv
- Forge geiger
forge geiger
- chisel?
- debugger?
- forge snapshot?
- script?