cast
TLDR
Get the balance of an address
SYNOPSIS
cast subcommand [options]
DESCRIPTION
cast is a command-line tool for interacting with Ethereum and EVM-compatible blockchains. It's part of the Foundry toolkit and provides utilities for querying blockchain state, sending transactions, encoding/decoding data, and performing conversions.
Cast can interact with deployed contracts by calling view functions or sending state-changing transactions. It handles ABI encoding/decoding, making it easy to work with smart contracts from the command line.
The tool also provides utilities for working with Ethereum data formats, including conversions between wei/ether, hex/decimal, and various encoding schemes. It integrates with Etherscan-like services for signature lookups.
PARAMETERS
call contract sig [args]
Call a contract function (read-only).send contract sig [args]
Send a transaction to a contract.balance address
Get ETH balance of address.block [number]
Get block information.tx hash
Get transaction details.receipt hash
Get transaction receipt.gas-price
Get current gas price.abi-encode sig [args]
ABI encode function call data.abi-decode sig data
Decode ABI-encoded data.sig signature
Get function selector (4 bytes).4byte-decode selector
Look up function signature.to-wei amount
Convert ether to wei.from-wei amount
Convert wei to ether.--rpc-url url
Ethereum RPC endpoint.--private-key key
Private key for signing.--chain chain
Chain name or ID.
CAVEATS
Requires access to an Ethereum RPC endpoint. Private keys should be handled securely (use environment variables or keystore). Gas estimation may be inaccurate for complex transactions. Some functions require an Etherscan API key for signature lookups.
HISTORY
cast is part of Foundry, developed by Georgios Konstantopoulos and the Paradigm team, announced in December 2021. Foundry was created as a fast, portable Ethereum development toolkit written in Rust, inspired by DappTools. Cast provides the CLI utilities while Forge handles testing and Anvil provides local nodes.


