Foundry (Cheat Sheet)

Foundry comes with four main binaries forge , cast , anvil , and chisel .

Forge tests, builds, and deploys your smart contracts.

Cast is Foundry’s command-line tool for performing Ethereum RPC calls. You can make smart contract calls, send transactions, or retrieve any type of chain data - all from your command-line!

Anvil is a local testnet node shipped with Foundry. You can use it for testing your contracts from frontends or for interacting over RPC.

Chisel is an advanced Solidity REPL shipped with Foundry. It can be used to quickly test the behavior of Solidity snippets on a local or forked network.

Here are links to the commands you can run with each of these binaries:


Running foundryup by itself will install the latest (nightly)  precompiled binaries forgecastanvil, and chisel. See foundryup --help for more options, like installing from a specific version or commit.



Generate event signature


$ cast sig-event "Transfer(address indexed from, address indexed to, uint256 amount)"

$ cast sig-event "event ValidatorGroupVoteActivated(address indexed account,address indexed group,uint256 value,uint256 units)"

For example, when filtering event logs using topic0 on .

FROM celo.logs
WHERE contract_address = 0x8d6677192144292870907e3fa8a5527fe55a7ff6 -- ElectionProxy
    AND topic0 = 0x45aac85f38083b18efe2d441a65b9c1ae177c78307cb5a5d4aec8f7dbcaeabfe -- ValidatorGroupVoteActivated

Convert decimal to hex


$ cast to-hex "22584960"

For example, block numbers must be in hex representation in JSON-RPC requests:

    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [
            "fromBlock": "0x1589e80",
            "toBlock": "0x1589e80"
    "id": 0