cast mktx


cast-mktx - Build and sign a transaction.


cast mktx [options] to [sig] [args…]


Build and sign a transaction, without publishing it.

The destination (to) can be an ENS name or an address.

The signature (sig) can be:

  • A fragment: someFunction(uint256,bytes32)
  • A selector and encoded calldata: 0xcdba2fd40000000000000000000000000000000000000000000000000000000000007a69
  • Only the function name: in this case Cast will try to fetch the function signature from Etherscan


Transaction Options

--gas-limit gas_limit
    Gas limit for the transaction.

--gas-price price
    Gas price for the transaction, or max fee per gas for EIP1559 transactions.

--priority-gas-price price
    Max priority fee per gas for EIP1559 transactions.

--value value
    Ether to send in the transaction.

    Either specified as an integer (wei), or as a string with a unit, for example:
    - 1ether
    - 10gwei
    - 0.01ether

--nonce nonce
    Nonce for the transaction.

    Send a legacy transaction instead of an EIP1559 transaction.

    This is automatically enabled for common networks without EIP1559.

--create code [sig args…]
    Deploy a contract by specifying raw bytecode, in place of specifying a to address.


--interactive <NUM>
     Open an interactive prompt to enter your private key. Takes a value for the number of keys to enter.
     Defaults to 0.

--mnemonic-derivation-path <PATHS>
     The wallet derivation path. Works with both --mnemonic-path and hardware wallets.

--mnemonic-indexes <INDEXES>
     Use the private key from the given mnemonic index. Used with --mnemonic-paths.
     Defaults to 0.

--mnemonic-passphrase <PASSPHRASE>
     Use a BIP39 passphrases for the mnemonic.

--mnemonic <PATHS>
     Use the mnemonic phrases or mnemonic files at the specified paths.

--private-key <RAW_PRIVATE_KEY>
     Use the provided private key.

--private-keys <RAW_PRIVATE_KEYS>
     Use the provided private keys.

Wallet Options - Keystore

--keystore path
    Use the keystore in the given folder or file.
    Environment: ETH_KEYSTORE

--account account-name
    Use a keystore from the default keystores folder (~/.foundry/keystores) by its filename.


--password password
    The keystore password. Used with --keystore.     Environment: ETH_PASSWORD

Wallet Options - Hardware Wallet

    Use a Trezor hardware wallet.

    Use a Ledger hardware wallet.

RPC Options

--rpc-url url
    The RPC endpoint. Accepts a URL or an existing alias in the [rpc_endpoints] table, like mainnet.     Environment: ETH_RPC_URL

    Use the Flashbots RPC URL (

Etherscan Options

--chain chain_name
    The Etherscan chain.

--etherscan-api-key key
    Etherscan API key, or the key of an Etherscan configuration table.
    Environment: ETHERSCAN_API_KEY

Common Options

    Prints help information.


  1. Sign a transaction that sends some ether to Vitalik using your Ledger:

    cast mktx --ledger vitalik.eth --value 0.1ether
  2. Sign a transaction that calls deposit(address token, uint256 amount) on a contract:

    cast mktx --ledger 0x... "deposit(address,uint256)" 0x... 1
  3. Sign a transaction that calls a function that expects a struct:

    contract Test {
        struct MyStruct {
            address addr;
            uint256 amount;
        function myfunction(MyStruct memory t) public pure {}

    Structs are encoded as tuples (see struct encoding)

    cast mktx 0x... "myfunction((address,uint256))" "(0x...,1)"
  4. Sign a transaction with hex data in the input field of the transaction object:

    cast mktx 0x... 0x68656c6c6f20776f726c64


cast, cast publish, cast send, struct encoding