This repository proposes a template that is based on foundry frameworks. It also provides templates for EVM compatible smart contracts (in ./contracts/example), tests and deployment scripts.
You can install all dependencies by running
yarn
forge iIn order to interact with non local networks, you must create an .env that has:
- PRIVATE_KEY
- MNEMONIC
- network key (eg. ALCHEMY_NETWORK_KEY)
- ETHERSCAN_API_KEY
For additional keys, you can check the .env.example file.
Warning: always keep your confidential information safe.
To automatically create headers, follow: https://github.com/Picodes/headers
Follow these instructions to have hardhat command line arguments completion: https://hardhat.org/hardhat-runner/docs/guides/command-line-completion
curl -L https://foundry.paradigm.xyz | bash
source /root/.zshrc
# or, if you're under bash: source /root/.bashrc
foundryupTo install the standard library:
forge install foundry-rs/forge-stdTo update libraries:
forge updateIf you donβt want to install Rust and Foundry on your computer, you can use Docker Image is available here ghcr.io/foundry-rs/foundry.
docker pull ghcr.io/foundry-rs/foundry
docker tag ghcr.io/foundry-rs/foundry:latest foundry:latestTo run the container:
docker run -it --rm -v $(pwd):/app -w /app foundry shThen you are inside the container and can run Foundryβs commands.
You can run tests as follows:
forge test -vvvv --watch
forge test -vvvv --match-path contracts/forge-tests/KeeperMulticall.t.sol
forge test -vvvv --match-test "testAbc*"
forge test -vvvv --fork-url https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdfYou can also list tests:
forge test --list
forge test --list --json --match-test "testXXX*"There is an example script in the scripts/foundry folder. Then you can run:
yarn foundry:deploy <FILE_NAME> --rpc-url <NETWORK_NAME>Example:
yarn foundry:deploy scripts/foundry/DeployMockAgEUR.s.sol --rpc-url goerliWe recommend the use of this vscode extension.
yarn hardhat:coverage
yarn foundry:coverageYou can simulate your transaction live or in fork mode. For both option you need to
complete the scripts/foundry/Simulate.s.sol with your values: address sending the tx,
address caled and the data to give to this address call.
For live simulation
yarn foundry:simulateFor fork simulation
yarn foundry:fork
yarn foundry:simulate:forkFor fork simulation at a given block
yarn foundry:fork:block ${XXXX}
yarn foundry:simulate:forkyarn foundry:gaspip3 install slither-analyzer
pip3 install solc-select
solc-select install 0.8.11
solc-select use 0.8.11
slither .Don't hesitate to reach out on Twitter π¦