TRY ONLINE

Works for output data, same as running `cast calldata-decode`. abi-decode can also decode input data with the `--input` flag, but it is the same as running `cast calldata-decode`, 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 abi-decode "balanceOf(address)(uint256)" 0x000000000000000000000000000000000000000000000000000000000000000a
10
Decode output data for getReserves() functions (no parameters) that returns three uint values:
cast abi-decode '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 abi-decode "getValidators()(address[])" 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001234567890123456789012345678901234567890000000000000000000000000abcdefabcdefabcdefabcdefabcdefabcdefabcd
[0x1234567890123456789012345678901234567890, 0xABcdEFABcdEFabcdEfAbCdefabcdeFABcDEFabCD]
Decode input data for a transfer call (same as running `cast calldata-decode`):
cast abi-decode --input "transfer(address,uint256)" 0xa9059cbb0000000000000000e78388b4ce79068e89bf8aa7f218ef6b9ab0e9d0000000000000000000000000000000000000000000000000008a8e4b1a3d8000
0xE78388b4CE79068e89Bf8aA7f218eF6b9AB0e9d0 39000000000000000 [3.9e16]

DOCUMENTATION

cast abi-decode


NAME

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

SYNOPSIS

cast abi-decode [options] sig calldata

DESCRIPTION

Decode ABI-encoded input or output data.

By default, the command will decode output data. To decode input data, pass --input or use cast calldata-decode.

The signature (sig) is a fragment in the form <function name>(<types...>)(<types...>).

OPTIONS

Decoder Options

-i
--input
    Decode input data.

Common Options

-h
--help
    Prints help information.

EXAMPLES

  1. Decode output data for a balanceOf call:

    cast abi-decode "balanceOf(address)(uint256)" \
      0x000000000000000000000000000000000000000000000000000000000000000a
    
  2. Decode input data for a transfer call:

    cast abi-decode --input "transfer(address,uint256)" \
      0xa9059cbb000000000000000000000000e78388b4ce79068e89bf8aa7f218ef6b9ab0e9d0000000000000000000000000000000000000000000000000008a8e4b1a3d8000
    

SEE ALSO

cast, cast calldata-decode