- Install Juan Blanco
- Install Solidity Visual Auditor
$ forge init my-project --template https://github.com/trozler/foundry-template
$ cd my-project
$ forge install
$ npm i
$ forge build
$ forge test
When installing dependencies to forge, please include the remapping in remappings.txt
, this will stop Juan Blanco extension complaining.
This template comes with GitHub Actions pre-configured. Your contracts will be linted and tested on every push and pull
request made to the main
/master
branch.
You can edit the CI script in .github/workflows/ci.yml.
This template uses Husky to run automated checks on commit messages, and Lint Staged to automatically format the code with Prettier when making a git commit.
Here's a list of the most frequently needed commands.
Build the contracts:
$ forge build
Delete the build artifacts and cache directories:
$ forge clean
Deploy to Anvil:
$ forge script script/SampleContract.s.sol:SampleContract --fork-url http://localhost:8545 \
--broadcast --private-key $PRIVATE_KEY
For instructions on how to deploy to a testnet or mainnet, check out the Solidity Scripting tutorial.
Run the tests:
$ forge test
Get a gas report:
$ forge test --gas-report
Get a gas snapshot:
$ forge snapshot
Lint the contracts:
$ npm run lint
Format the contracts with Prettier:
$ npm run prettier:write
https://book.getfoundry.sh/index.html https://github.com/foundry-rs/foundry
Inspired by Rari-Capital/solmate, and paulberg/foundry-template.