Foundry
Installation
(For Linux and MacOS Users)
Install foundryup:
curl -L https://foundry.paradigm.xyz | bashThis will download foundryup. Then install Foundry by running:
foundryupBasic Commands
To start a new project with Foundry:
forge init hello_foundryCompile Solidity code:
forge buildRun Solidity tests:
forge test -vvvv Install Dependencies
Generate remappings for installed libraries
Update Dependencies
Unit Testing
Fuzz Testing
Fuzz testing is done by using a range of randomized possible inputs to test for edge cases, instead of just testing it with select inputs as in unit testing.
Foundry lets us do this natively.
To run these fuzz tests, use:
Additional Security
Checking Test Coverage
Static Analysis (Slither)
Invariant Testing
Deployment
Create .env file in root folder:
Update foundry.toml:
SampleContract.s.sol
To run the above script:
To deploy SampleContract to a live testnet, run the following in your terminal:
Verification
To verify an existing contract:
Check verification status:
References:
https://book.getfoundry.sh/tutorials/solidity-scripting#deploying-our-contract
Last updated