Skip to main content
Glama

evm_decode_function_result

Decode hex-encoded EVM function return data with a contract ABI and function name to interpret call results and transaction outputs as named values.

Instructions

Decode function return data from transaction or call.

Takes hex-encoded return data and decodes it according to the function's return types defined in the ABI. Essential for interpreting contract call results and transaction outputs.

CRITICAL RULES:

  • Requires correct ABI for function being decoded

  • Data must be hex-encoded return data (0x-prefixed)

  • Returns both formatted (named) and raw (array) results

  • Handles BigInt serialization for JSON compatibility

  • Function must have return values defined in ABI

PARAMETERS:

  • chain: EVM chain context (required)

  • abi: Contract ABI (required)

  • functionName: Function name that returned this data (required)

  • data: Hex-encoded return data to decode (required)

EXAMPLES: ✅ Decode ERC20 balance: {chain: "polygon", abi: [...ERC20_ABI], functionName: "balanceOf", data: "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"}

✅ Decode multiple return values: {chain: "ethereum", abi: [...], functionName: "getReserves", data: "0x..."}

✅ Decode struct returns: {chain: "arbitrum", abi: [...], functionName: "getPoolInfo", data: "0x..."}

❌ Invalid - wrong function name: {functionName: "wrongFunction", data: "0x..."} // ABI mismatch

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: • decodedResult: Formatted result with named outputs • rawResult: Raw array of decoded values • functionName: Function that was decoded

COMMON MISTAKES:

  • Using wrong ABI for decoding

  • Mismatched function name

  • Truncated or malformed data

  • Not handling BigInt values properly

USE CASES:

  • Interpret contract call results

  • Decode transaction return data

  • Parse multicall results

  • Debug contract interactions

  • Extract values from view function calls

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>",
      "functionName": "<functionName>",
      "data": "<data>"
    },
    "name": "evm_decode_function_result"
  }
}

Input Schema

NameRequiredDescriptionDefault
abiYesContract ABI
dataYesHex-encoded return data to decode
chainYesEVM chain context
functionNameYesFunction name that returned this data

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.6/5.0
Behavior4/5

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

With no annotations supplied, the description carries the full burden and does reasonably well: it states the return shape (decodedResult, rawResult, functionName), discloses BigInt serialization handling, and warns that the function must have return values defined in the ABI. It does not discuss error behavior when data or ABI mismatch beyond listing it as a mistake, nor whether decoding is purely local/offline.

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 core purpose is front-loaded, but the description is heavily padded with material irrelevant to decoding: seven-chain gas commentary, testnet token/facuet notes, and unrelated Linux package-manager instructions. Those blocks bury the genuinely useful rules and mistakes, and a decoding tool has no use for gas-timing advice.

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

Completeness3/5

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

For a four-parameter read-only decode tool the description covers inputs, outputs, examples, and pitfalls adequately, and there is no output schema to compensate for. However, it omits any differentiation from the closely related evm_decode_contract_data and evm_encode_function_data siblings, leaving the agent to guess which decoder applies.

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 description coverage is 100%, so the four parameters are already documented, and the description's parameter list largely restates them. It does add one useful constraint not in the schema — data must be 0x-prefixed hex — and the worked examples show realistic values (e.g. ERC20 balanceOf decoding), but abi and chain semantics get no extra depth.

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 pairs a specific verb and resource ("Decode function return data from transaction or call") and the second sentence explains the mechanism (hex data decoded per ABI return types). It is unambiguous what the tool does, though it never explicitly names the near-identical sibling evm_decode_contract_data to draw the distinction between them.

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

Usage Guidelines4/5

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

The USE CASES block (interpreting call results, parsing multicall results, debugging interactions) gives concrete context for when to reach for this tool, and the COMMON MISTAKES section plus the ❌ wrong-function-name example flag failure modes. What's missing is an explicit when-not/alternative statement routing the agent to evm_encode_function_data or evm_decode_contract_data.

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