Skip to main content
Glama

evm_decode_contract_data

Decode raw EVM transaction input data using a contract ABI to reveal the called function and parameters for debugging, auditing, or verifying contract interactions.

Instructions

Decode transaction input data to understand what function was called and with what parameters.

Takes raw hex transaction data and ABI to decode function name and parameters. Essential for understanding transactions on block explorers, auditing contract interactions, and debugging failed transactions.

CRITICAL RULES:

  • Requires correct ABI for contract being decoded

  • Data must start with function selector (first 4 bytes)

  • Parameters decoded based on ABI parameter types

  • Decoding only works if ABI matches contract

  • Complex types (tuples, arrays) properly structured in output

PARAMETERS:

  • chain: EVM chain context (required)

    • Used for context, doesn't affect decoding

    • Helps identify which chain's transaction

  • abi: Contract ABI (required)

    • Must include function being decoded

    • Function selector computed from signature

    • All parameter types must be defined

    • Get from block explorer or project docs

  • data: Transaction input data to decode (required)

    • Format: 0x followed by hex characters

    • First 4 bytes: function selector

    • Remaining bytes: encoded parameters

    • Get from transaction details on block explorer

EXAMPLES: ✅ Decode ERC20 transfer transaction: {chain: "polygon", abi: [...ERC20_ABI], data: "0xa9059cbb000000000000000000000000742d35cc6634c0532925a3b844bc9e7595f0beb0000000000000000000000000000000000000000000000000de0b6b3a7640000"}

✅ Decode DEX swap transaction: {chain: "arbitrum", abi: [...ROUTER_ABI], data: "0x38ed1739..."}

✅ Decode NFT mint transaction: {chain: "ethereum", abi: [...NFT_ABI], data: "0xa0712d68..."}

❌ Invalid - wrong ABI: {abi: [...ERC721_ABI], data: "0xERC20TransferData"} // ABI mismatch

❌ Invalid - invalid data format: {data: "not-hex-data"} // Must be 0x... hex string

SUPPORTED EVM CHAINS (7 networks): • ethereum (Sepolia) - EIP-1559 enabled, ~12s blocks, moderate gas costs • polygon (Amoy) - Low fees, fast finality (~2s), layer 2 • avalanche (Fuji C-Chain) - Sub-second finality, dynamic fees • bsc (BNB Testnet) - 3s blocks, low gas costs, Binance ecosystem • arbitrum (Sepolia) - Optimistic rollup, low fees, Ethereum security • base (Sepolia) - Coinbase layer 2, EIP-1559, low fees • worldchain (World Sepolia) - World Network testnet, EIP-1559

CRITICAL GAS CONSIDERATIONS:

  • Ethereum: High gas costs, use gas oracle for timing

  • Polygon/BSC: Very low gas, safe for frequent transactions

  • Arbitrum/Base: L2 optimizations, ~10-50x cheaper than Ethereum

  • Avalanche: Dynamic fees, can spike during congestion

  • Always check gas price before executing transactions

TESTNET TOKENS: All chains use testnet tokens with NO REAL VALUE. Faucets available for all supported networks.

OUTPUT STRUCTURE: • success: Boolean indicating decoding success • chain: Chain context • functionName: Name of function called • functionSignature: Full function signature • parameters: Array of decoded parameters with names and values • methodId: Function selector (first 4 bytes) • decodedData: Human-readable representation • executionTime: Time taken in milliseconds

COMMON MISTAKES:

  • Using wrong ABI (from different contract)

  • Missing function definition in ABI

  • Truncated or malformed data

  • Not handling complex parameter types

  • Confusing input data with output data

USE CASES:

  • Understand what a transaction does before executing

  • Audit historical transactions

  • Debug failed transactions

  • Verify transaction parameters

  • Build transaction explorers

FUNCTION SELECTOR: First 4 bytes of input data:

  • Computed from function signature

  • Example: transfer(address,uint256)

  • Keccak256 hash, first 4 bytes

  • Used to identify function being called

DECODING PROCESS:

  1. Extract function selector (first 4 bytes)

  2. Match selector to function in ABI

  3. Extract parameter types from ABI

  4. Decode remaining data using types

  5. Return function name and parameters

PARAMETER TYPES: Common Solidity types decoded:

  • address: Ethereum addresses

  • uint256: Large integers (as strings)

  • bytes: Byte arrays

  • string: Text strings

  • bool: True/false

  • arrays: Multiple values

  • tuples: Structured data

EXAMPLE DECODED OUTPUT: { functionName: "transfer", parameters: [ {name: "recipient", type: "address", value: "0x742d35..."}, {name: "amount", type: "uint256", value: "1000000000000000000"} ] }

WHERE TO GET INPUT DATA:

  1. Block explorer transaction details

  2. Pending transaction before broadcast

  3. Transaction receipt logs

  4. Wallet transaction history

  5. Contract event logs

DEBUGGING FAILED TRANSACTIONS:

  1. Get failed transaction hash

  2. View on block explorer

  3. Copy input data

  4. Decode with this tool

  5. Understand what was attempted

  6. Fix parameters and retry

COMPLEX TYPES: Arrays and tuples decoded recursively:

  • address[]: ["0x...", "0x...", "0x..."]

  • (uint256,string): {amount: "100", name: "Token"}

  • Nested structures: Full object hierarchy

SECURITY AUDITING: Use to verify transactions:

  • Check recipient addresses

  • Verify amounts being transferred

  • Confirm function being called

  • Detect suspicious patterns

  • Audit contract interactions

Running on Linux.

LINUX-SPECIFIC NOTES:

  • Package manager: apt (Ubuntu/Debian), yum (RHEL/CentOS), or pacman (Arch)

  • Python 3 is typically 'python3' command

  • GNU tools are standard

  • Use 'xdg-open' command to open files/applications

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "chain": "<chain>",
      "abi": "<abi>",
      "data": "<data>"
    },
    "name": "evm_decode_contract_data"
  }
}

Input Schema

NameRequiredDescriptionDefault
abiYesContract ABI (JSON array)
dataYesTransaction input data to decode (0x...)
chainYesEVM chain context

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and largely meets it: it discloses the decoding steps, the failure modes (wrong ABI, missing function, truncated/malformed data), how complex types are structured, and the convention that uint256 values return as strings. It also clarifies that the chain parameter is context-only and does not affect decoding. What it never states explicitly is that this is a local, non-mutating read operation with no on-chain side effects or network/RPC requirements—worth a line given the absence of a readOnlyHint.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The first sentence is well front-loaded, but the body balloons with material irrelevant to decoding: gas cost comparisons across chains, testnet faucet notes, supported-network block times, and a block of Linux package-manager and xdg-open advice. These sections do not earn their place in a calldata-decoding definition and push the genuinely useful decoding guidance far apart, hurting scanability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a three-parameter decoding utility with no output schema, the description is more than complete: it documents the OUTPUT STRUCTURE fields, decoded type mappings, an example decoded result, and error conditions. The only true gap is the unstated absence of side effects and whether any network call occurs, but overall an agent has everything needed to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3 under the rubric. The description does add some meaning beyond the schema—'chain is used for context, doesn't affect decoding,' 'ABI must include the function being decoded,' 'data must be 0x-prefixed hex with a 4-byte selector'—which makes it slightly better than pure restatement, but much of the parameter prose overlaps with the schema descriptions rather than extending them.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening line gives a specific verb and resource: 'Decode transaction input data to understand what function was called and with what parameters.' That is precise enough for an agent to distinguish it from encoding tools. However, it never names its closest sibling (evm_decode_function_result, which decodes output/return data), so the input-vs-output boundary is only hinted at indirectly via the 'Confusing input data with output data' mistake bullet.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The USE CASES and DEBUGGING FAILED TRANSACTIONS sections give clear contextual situations for using the tool, and the ✅/❌ examples show valid and invalid calls. But there is no explicit routing guidance against alternatives—nothing says 'use evm_decode_function_result for return data' or 'use evm_encode_contract_data to build calldata instead.' Usage is implied rather than contrasted.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools