Foundry Reference

Mega CLI builds on top of Foundry, a powerful Ethereum development toolkit. This page provides a quick reference for Foundry tools that are used within Mega CLI.

For comprehensive documentation, refer to the Foundry Book, which is the official documentation.

Foundry Components

Foundry consists of four main tools that are used throughout Mega CLI:

Forge

Forge is a testing framework for Ethereum smart contracts.

# Test your contracts
forge test

# Run a specific test
forge test --match-test testFunctionName

# Run tests with verbosity
forge test -vvv

Cast

Cast is a command-line tool for interacting with EVM smart contracts, sending transactions, and getting chain data.

# Get account balance
cast balance <address> --rpc-url <rpc-url>

# Call a contract function
cast call <contract-address> "functionName(uint256)" 123

# Send a transaction
cast send <contract-address> "functionName(uint256)" 123 --private-key <private-key>

Anvil

Anvil is a local Ethereum node designed for development with configurable options.

# Start a local node
anvil

# Start with a specific chain ID
anvil --chain-id 1337

# Start with a specific block time
anvil --block-time 5

Chisel

Chisel is a Solidity REPL (Read-Eval-Print Loop) for quick code testing and prototyping.

# Start Chisel
chisel

# In Chisel, you can write and execute Solidity code directly
uint256 x = 5;
uint256 y = 10;
uint256 z = x + y;
z // Returns: 15

Additional Resources