Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 2.03 KB

README.md

File metadata and controls

92 lines (66 loc) · 2.03 KB

Foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

Foundry consists of:

  • Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
  • Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
  • Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
  • Chisel: Fast, utilitarian, and verbose solidity REPL.

Documentation

https://book.getfoundry.sh/

Usage

Install

yarn install
forge install foundry-rs/forge-std --no-commit
forge install OpenZeppelin/openzeppelin-contracts-upgradeable@v5.1.0 --no-commit
forge install OpenZeppelin/openzeppelin-foundry-upgrades@v0.3.6 --no-commit

Build

$ forge build

Test

$ forge test

test a specific contract

forge test --match-contract SafeGuardTest -vvv
forge test --match-contract BuybackTest --match-test "testExecutorOfNoneOwner" -vvv

Format

$ forge fmt

Gas Snapshots

$ forge snapshot

Anvil

$ anvil

Deploy

$ forge script <path_to_script> --rpc-url <your_rpc_url> --private-key <your_private_key> --etherscan-api-key <bscscan-api-key> --broadcast --verify -vvv --via-ir
# deploy SafeGuard Contract
$ forge script script/safe/SafeGuard.s.sol:SafeGuardScript --rpc-url <your_rpc_url> --private-key <your_private_key> --etherscan-api-key <bscscan-api-key> --broadcast --verify -vvv

Verify

$ forge verify-contract --rpc-url <your_rpc_url> --chain-id <chain-id> <address> <contract-name> --api-key <bscscan-api-key>

Cast

$ cast <subcommand>
$ cast call <contract_address> <method_name> <method_args>
$ cast send <contract_address> <method_name> <method_args> --private-key <private_key>
# demo
$ cast send <contract_address> "addExecutor(address)" <...parameters> --rpc-url $RPC --private-key $PRIVATE_KEY 

Help

$ forge --help
$ anvil --help
$ cast --help