cast

NAME

cast - Perform Ethereum RPC calls from the comfort of your command line.

SYNOPSIS

cast [options] command [args] cast [options] --version cast [options] --help

DESCRIPTION

This program is a set of tools to interact with Ethereum and perform conversions.

COMMANDS

General Commands

cast help     Display help information about Cast.

cast completions     Generate shell autocompletions for Cast.

Chain Commands

cast chain-id     Get the Ethereum chain ID.

cast chain     Get the symbolic name of the current chain.

cast client     Get the current client version.

Transaction Commands

cast publish     Publish a raw transaction to the network.

cast receipt     Get the transaction receipt for a transaction.

cast send     Sign and publish a transaction.

cast call     Perform a call on an account without publishing a transaction.

cast rpc      Perform a raw JSON-RPC request [aliases: rp]

cast tx     Get information about a transaction.

cast run     Runs a published transaction in a local environment and prints the trace.

cast estimate     Estimate the gas cost of a transaction.

cast access-list     Create an access list for a transaction.

cast logs     Get logs by signature or topic

Block Commands

cast find-block     Get the block number closest to the provided timestamp.

cast gas-price     Get the current gas price.

cast block-number     Get the latest block number.

cast basefee     Get the basefee of a block.

cast block     Get information about a block.

cast age     Get the timestamp of a block.

Account Commands

cast balance     Get the balance of an account in wei.

cast storage     Get the raw value of a contract’s storage slot.

cast proof     Generate a storage proof for a given storage slot.

cast nonce     Get the nonce for an account.

cast code     Get the bytecode of a contract.

cast codesize     Get the runtime bytecode size of a contract.

ENS Commands

cast lookup-address     Perform an ENS reverse lookup.

cast resolve-name     Perform an ENS lookup.

cast namehash     Calculate the ENS namehash of a name.

Etherscan Commands

cast etherscan-source     Get the source code of a contract from Etherscan.

ABI Commands

cast abi-decode     Decode ABI-encoded input or output data.

cast abi-encode     ABI encode the given function arguments, excluding the selector.

cast 4byte     Get the function signatures for the given selector from https://sig.eth.samczsun.com.

cast 4byte-decode     Decode ABI-encoded calldata using https://sig.eth.samczsun.com.

cast 4byte-event     Get the event signature for a given topic 0 from https://sig.eth.samczsun.com.

cast calldata     ABI-encode a function with arguments.

cast calldata-decode     Decode ABI-encoded input data.

cast pretty-calldata     Pretty print calldata.

cast selectors     Extracts function selectors and arguments from bytecode

cast upload-signature     Upload the given signatures to https://sig.eth.samczsun.com.

Conversion Commands

cast format-bytes32-string     Formats a string into bytes32 encoding.

cast from-bin     Convert binary data into hex data.

cast from-fixed-point     Convert a fixed point number into an integer.

cast from-utf8     Convert UTF8 to hex.

cast from-wei     Convert wei into an ETH amount

cast parse-bytes32-address     Parses a checksummed address from bytes32 encoding.

cast parse-bytes32-string     Parses a string from bytes32 encoding.

cast to-ascii     Convert hex data to an ASCII string.

cast to-base     Convert a number of one base to another.

cast to-bytes32     Right-pads hex data to 32 bytes.

cast to-dec     Converts a number of one base to decimal

cast to-fixed-point     Convert an integer into a fixed point number.

cast to-hex     Converts a number of one base to another

cast to-hexdata     Normalize the input to lowercase, 0x-prefixed hex.

cast to-int256     Convert a number to a hex-encoded int256.

cast to-rlp     RLP encodes hex data, or an array of hex data

cast to-uint256     Convert a number to a hex-encoded uint256.

cast to-unit     Convert an ETH amount into another unit (ether, gwei, wei).

cast to-wei     Convert an ETH amount to wei.

cast shl     Perform a left shifting operation.

cast shr     Perform a right shifting operation.

Utility Commands

cast sig     Get the selector for a function.

cast sig-event     Generate event signatures from event string.

cast keccak     Hash arbitrary data using keccak-256.

cast compute-address     Compute the contract address from a given nonce and deployer address.

cast create2      Generate a deterministic contract address using CREATE2

cast interface     Generate a Solidity interface from a given ABI.

cast index     Compute the storage slot for an entry in a mapping.

cast concat-hex     Concatenate hex strings.

cast max-int     Get the maximum i256 value.

cast min-int     Get the minimum i256 value.

cast max-uint     Get the maximum u256 value.

cast to-check-sum-address     Convert an address to a checksummed format (EIP-55).

Wallet Commands

cast wallet     Wallet management utilities.

cast wallet new     Create a new random keypair.

cast wallet address     Convert a private key to an address.

cast wallet sign     Sign a message.

cast wallet vanity     Generate a vanity address.

cast wallet verify     Verify the signature of a message.

OPTIONS

Special Options

-V --version     Print version info and exit.

Common Options

-h
--help
    Prints help information.

EXAMPLES

  1. Call a function on a contract:

    cast call 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
      "balanceOf(address)(uint256)" 0x...
    
  2. Decode raw calldata:

    cast calldata-decode "transfer(address,uint256)" \
      0xa9059cbb000000000000000000000000e78388b4ce79068e89bf8aa7f218ef6b9ab0e9d0000000000000000000000000000000000000000000000000008a8e4b1a3d8000
    
  3. Encode calldata:

    cast calldata "someFunc(address,uint256)" 0x... 1
    

BUGS

See https://github.com/foundry-rs/foundry/issues for issues.