Foundry Cheat Sheet - Every Command You Need (2026)

Foundry Cheat Sheet - Every Command You Need (2026)

DevTools Store

Foundry Cheat Sheet - Every Command You Need (2026)

Complete Foundry reference. Forge, Cast, Anvil, Chisel. Smart contract development.

Web3 dev tools for $1+ (ETH): https://rentry.co/dev-tools-pay-what-you-want

Install

curl -L https://foundry.paradigm.xyz | bash && foundryup

Project Setup

forge init my-project # Create new project

forge build # Compile contracts

forge test # Run tests

forge test -vvvv # Verbose test output

Testing

function testTransfer() public { token.transfer(alice, 100); assertEq(token.balanceOf(alice), 100); }

function testRevert() public { vm.prank(alice); vm.expectRevert(); token.transfer(bob, 1000); }

vm.deal(alice, 10 ether); // Give ETH

vm.warp(block.timestamp + 1 days); // Fast forward time

vm.prank(alice); // Impersonate address

Deploy

forge create src/Token.sol:Token --rpc-url $RPC --private-key $KEY --constructor-args 'MyToken' 'MTK'

forge script script/Deploy.s.sol --rpc-url $RPC --broadcast

Cast (CLI Tool)

cast balance 0x... --rpc-url $RPC

cast send 0x... 'transfer(address,uint256)' 0xAlice 100 --rpc-url $RPC --private-key $KEY

cast call 0x... 'balanceOf(address)(uint256)' 0xAlice --rpc-url $RPC

cast interface 0x... --rpc-url $RPC # Get ABI from contract

Anvil (Local Node)

anvil # Start local Ethereum node

anvil --fork-url https://eth-mainnet.publicnode.com # Fork mainnet

Default accounts: 10 accounts with 10,000 ETH each

RPC URL: http://localhost:8545

Useful Flags

--optimize # Optimize compilation

--via-ir # Use IR pipeline (complex contracts)

--gas-report # Show gas usage

---

More Web3 cheat sheets: https://rentry.co/pgib9826

Report Page