Cast
Cast performs Ethereum RPC calls, sends transactions, and decodes data from the command line. It's the Swiss Army knife for blockchain interaction.
Cast works both inside and outside a Foundry project.
Key capabilities
| Feature | Description |
|---|---|
| Chain data | Read blocks, transactions, logs, and account state |
| Transactions | Send transactions and interact with contracts |
| Wallets | Manage keys, sign messages, and verify signatures |
| ABI encoding | Encode/decode calldata, events, and function signatures |
| Utilities | Convert units, compute hashes, and manipulate data |
Common workflows
Get the latest block number
$ cast block-numberRead a contract's storage
$ cast call $CONTRACT "balanceOf(address)" $ADDRESSSend a transaction
$ cast send $CONTRACT "transfer(address,uint256)" $TO $AMOUNT --private-key $KEYDecode calldata
$ cast 4byte-decode 0xa9059cbb000000000000000000000000...Get an account's ETH balance
$ cast balance $ADDRESSLearn more
- Reading chain data — Query blocks, transactions, and state
- Sending transactions — Execute on-chain operations
- Wallet operations — Key management and signing
- ABI encoding — Encode and decode contract data
- Reference — Full CLI reference
Was this helpful?
