Example repo to demonstrate the functionality of the foundry smart contract development framework. Foundry is set apart by several advantages:
- Tests / Scripts etc. are all written in solidity avoiding switching between JS and Solidity during development
- Efficient implementation in Rust leads to massive speedup vs. other tools.
- Powerful testing tools such as fuzzing, invariant tests (and soon symbolic execution)
- Easy manipulation of the blockchain state etc. using Cheatcodes
The best source of documentation is the foundry-book which contains chapters on all elements of the framework.
- Install
foundryup
tool by runningcurl -L https://foundry.paradigm.xyz | bash
- Install / Update foundry with
foundryup
Foundry consists of three main tools which have separate command line interfaces:
forge
: Solidity development framework including Tests, Scripting, Compilation, Formatting etc. (Focus of this demo repo)anvil
: Runs local test node (similar tohardhat node
)cast
: Various tools for interacting with contracts on chain directly from the command line. (Executing calls, analysing interfaces, transactions etc)
Help on any of the below command can be found with forge COMMAND --help
forge init
(useful options --no-commit
, --force
)
forge install openzeppelin/openzeppelin-contracts
(Specify github repo owner/name to select depency)
forge build
forge test
(useful options --fork-url
, --match-test
...)
forge script script/ContractScript.sol:ContractScript
(useful options --rpc-url
, --private-key
, --slow
, --broadcast
...)