Skip to main content

Decode

Decodes transaction input or output data using a smart contract ABI, converting raw hexadecimal data into readable structured format.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • ABI - The ABI ID from the Parse ABI node.
  • ABI Method - The name of the method whose data you want to decode.
  • Data - The hexadecimal data to decode (transaction input or contract call response).

Output

  • Struct - The decoded data as a structured object with readable values.

Options

  • Input/Output - Select whether to decode:
    • Input - Decode transaction input data (function arguments)
    • Output - Decode contract call response data (return values)

How It Works

The Decode node converts encoded blockchain data to readable format. When executed, the node:

  1. Validates the ABI ID and retrieves the parsed ABI
  2. Finds the specified method in the ABI
  3. Removes the function signature hash from the data (for input)
  4. Decodes the remaining data according to the method's inputs or outputs
  5. Returns a structured object with decoded values

Requirements

  • A valid ABI ID from the Parse ABI node
  • The correct method name matching the encoded data
  • Valid hexadecimal data (with or without "0x" prefix)
  • The ABI must contain the specified method

Error Handling

The node will return errors for:

  • Invalid or missing ABI ID
  • ABI not found (Parse ABI must be called first)
  • Method not found in ABI
  • Invalid hexadecimal data
  • Data length mismatch with method signature
  • Decoding failures

Usage Notes

  • The "0x" prefix is automatically handled and can be included or omitted
  • For input decoding, the function selector (first 4 bytes) is automatically removed
  • Output decoding expects just the return value data
  • Multiple return values are decoded into an array or object
  • Complex types (structs, arrays) are properly parsed

Example

Decoding ERC20 transfer input:

Inputs:

  • ABI: a1b2c3d4-e5f6-7g8h-9i0j-k1l2m3n4o5p6
  • ABI Method: transfer
  • Data: 0xa9059cbb000000000000000000000000742d35cc6634c0532925a3b844bc9e7595f0beb0000000000000000000000000000000000000000000000000000000005f5e100

Options:

  • Input/Output: Input

Output:

{
"recipient": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"amount": "100000000"
}

Decoding balanceOf output:

Inputs:

  • ABI: a1b2c3d4-e5f6-7g8h-9i0j-k1l2m3n4o5p6
  • ABI Method: balanceOf
  • Data: 0x0000000000000000000000000000000000000000000000000000000005f5e100

Options:

  • Input/Output: Output

Output:

{
"balance": "100000000"
}

Common Use Cases

Transaction Analysis: Decode transaction input to understand what function was called and with what arguments.

Response Parsing: Decode contract call responses to extract return values.

Event Log Decoding: Parse event log data to extract emitted values.

Audit Trail: Create readable records of contract interactions.

Transaction Verification: Verify transaction parameters match expected values.

Multi-Return Functions: Extract multiple return values from contract calls.

Decoding Different Data Types

Simple Types:

// address
"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"

// uint256
"1000000000000000000"

// bool
true

// string
"Hello, World!"

Arrays:

// address[]
[
"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"0x1234567890123456789012345678901234567890"
]

// uint256[]
["100", "200", "300"]

Structs:

{
"name": "Token Name",
"symbol": "TKN",
"decimals": 18,
"totalSupply": "1000000000000000000000000"
}

Input vs Output Decoding

Input Decoding:

  • Decodes function arguments
  • Includes function selector removal
  • Use for transaction.input data
  • Results show what was sent to the contract

Output Decoding:

  • Decodes return values
  • No function selector present
  • Use for Call response data
  • Results show what the contract returned

Complete Workflow Examples

Analyzing a transaction:

  1. Get Transaction - Retrieve transaction by hash
  2. Extract Input - Get the input field from transaction
  3. Decode - Decode with Input mode
  4. Process - Use decoded parameters

Processing contract call response:

  1. ABI Method - Encode function call
  2. Call - Execute read-only call
  3. Decode - Decode with Output mode
  4. Extract - Use returned values

Decoding Event Logs

For event logs from Transaction Receipt:

  1. Get the log data and topics
  2. Use Decode with the event name
  3. Set mode to Input (events use input format)
  4. Parse the decoded event parameters

Example event log:

{
"address": "0x...",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", // Transfer event signature
"0x000000000000000000000000742d35cc6634c0532925a3b844bc9e7595f0beb", // from (indexed)
"0x0000000000000000000000001234567890123456789012345678901234567890" // to (indexed)
],
"data": "0x0000000000000000000000000000000000000000000000000000000005f5e100" // amount
}

Decode the data field to get the non-indexed parameters.

Error Messages

"ABI not found"

  • Run Parse ABI node first
  • Verify the ABI ID is correct

"Method not found"

  • Check method name spelling (case-sensitive)
  • Verify the method exists in the ABI

"Cannot decode data"

  • Data length doesn't match expected parameters
  • Data may be for a different method
  • Corrupted or invalid hex data

Advanced Usage

Decoding with unknown method:

If you don't know which method was called:

  1. Extract the first 4 bytes (function selector)
  2. Try decoding with different methods
  3. Match against known function signatures

Validating decoded data:

decoded = decodeNode.output

// Validate address
if (!decoded.recipient.startsWith('0x')) {
throw new Error("Invalid address format")
}

// Validate amount
if (BigInt(decoded.amount) <= 0) {
throw new Error("Invalid amount")
}
tip

For complex contract interactions, decode both the transaction input (to see what was requested) and the call output (to see what was returned).

info

The Decode node automatically handles data type conversions. Numbers are returned as strings to preserve precision for large values (uint256).

warning

Always verify the decoded data makes sense for the method you're decoding. Decoding with the wrong method will produce garbage output or errors.

Type Mapping

Solidity → JavaScript:

  • address → string (0x...)
  • uint → string (decimal number)
  • int → string (decimal number)
  • bool → boolean
  • string → string
  • bytes → string (0x...)
  • array → Array
  • struct → Object