TRY ONLINE

Works for output data, same as running `cast decode-calldata`. decode-abi can also decode input data with the `--input` flag, but it is the same as running `cast decode-calldata`, so you can just use that instead.
Signature
Data
Decoded
Decoded data will appear here

EXAMPLES

Decode output data for a balanceOf call (if there's no parameter, then it decodes output data):
cast decode-abi "balanceOf(address)(uint256)" 0x000000000000000000000000000000000000000000000000000000000000000a
10
Decode output data for getReserves() functions (no parameters) that returns three uint values:
cast decode-abi 'getReserves()(uint112,uint112,uint32)' 0x000000000000000000000000000000000000000000000000001a8908b3ee4280000000000000000000000000000000000000000000000000003ff289d54a6380000000000000000000000000000000000000000000000000000000006579add4
7469019865956992 [7.469e15] 17999597335634816 [1.799e16] 1702473172 [1.702e9]
Decode output data for getValidators() functions (no parameters) that returns an array of addresses:
cast decode-abi "getValidators()(address[])" 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001234567890123456789012345678901234567890000000000000000000000000abcdefabcdefabcdefabcdefabcdefabcdefabcd
[0x1234567890123456789012345678901234567890, 0xABcdEFABcdEFabcdEfAbCdefabcdeFABcDEFabCD]
Decode input data for a transfer call (same as running `cast decode-calldata`):
cast decode-abi --input "transfer(address,uint256)" 0xa9059cbb0000000000000000e78388b4ce79068e89bf8aa7f218ef6b9ab0e9d0000000000000000000000000000000000000000000000000008a8e4b1a3d8000
0xE78388b4CE79068e89Bf8aA7f218eF6b9AB0e9d0 39000000000000000 [3.9e16]

DOCUMENTATION

cast decode-abi


Decode ABI-encoded input or output data.

Defaults to decoding output data. To decode input data pass --input.

When passing --input, function selector must NOT be prefixed in calldata string

$ cast decode-abi --help
Usage: cast decode-abi [OPTIONS] <SIG> <CALLDATA>

Arguments:
  <SIG>
          The function signature in the format `<name>(<in-types>)(<out-types>)`

  <CALLDATA>
          The ABI-encoded calldata

Options:
  -h, --help
          Print help (see a summary with '-h')

  -j, --threads <THREADS>
          Number of threads to use. Specifying 0 defaults to the number of
          logical cores
          
          [aliases: --jobs]

Decode input data instead of output data:
  -i, --input
          Whether to decode the input or output data

Display options:
      --color <COLOR>
          The color of the log messages

          Possible values:
          - auto:   Intelligently guess whether to use color output (default)
          - always: Force color output
          - never:  Force disable color output

      --json
          Format log messages as JSON

  -q, --quiet
          Do not print log messages

  -v, --verbosity...
          Verbosity level of the log messages.
          
          Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv).
          
          Depending on the context the verbosity levels have different meanings.
          
          For example, the verbosity levels of the EVM are:
          - 2 (-vv): Print logs for all tests.
          - 3 (-vvv): Print execution traces for failing tests.
          - 4 (-vvvv): Print execution traces for all tests, and setup traces
          for failing tests.
          - 5 (-vvvvv): Print execution and setup traces for all tests,
          including storage changes.