Skip to main content
Glama

evm_encode_function_data

Encodes contract function calls into hex transaction input data. Use it to build raw transactions, batch operations, or multi-sig proposals before signing.

Instructions

Encode function call into transaction input data for raw transaction construction.

Converts function name and parameters into hex-encoded transaction data. Used for building raw transactions, batch operations, multi-sig proposals, or when you need transaction data before signing.

CRITICAL RULES:

  • Requires correct ABI for function being encoded

  • Parameters must match function signature exactly

  • Output is hex-encoded transaction input data

  • Can be used in raw transactions or eth_sendRawTransaction

  • Function selector automatically prepended to encoded parameters

PARAMETERS:

  • chain: EVM chain context (required)

  • abi: Contract ABI (required)

  • functionName: Name of function to encode (required)

  • params: Function parameters array (optional)

EXAMPLES: ✅ Encode ERC20 transfer: {chain: "polygon", abi: [...ERC20_ABI], functionName: "transfer", params: ["0x742d35Cc...", "1000000000000000000"]}

✅ Encode token approval: {chain: "arbitrum", abi: [...], functionName: "approve", params: ["0xSpender...", "115792089237316195423570985008687907853269984665640564039457584007913129639935"]}

✅ Encode function with no parameters: {chain: "ethereum", abi: [...], functionName: "totalSupply", params: []}

❌ Invalid - wrong parameter types: {params: [1000, "0xAddress"]} // Numbers should be strings

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: • encodedData: Hex-encoded transaction data (0x...) • selector: Function selector (first 4 bytes) • functionSignature: Full function signature

COMMON MISTAKES:

  • Wrong parameter types (number instead of string)

  • Incorrect parameter order

  • Missing required parameters

  • Using wrong ABI

  • Not converting values to proper units

USE CASES:

  • Build raw transactions manually

  • Prepare multi-sig transaction proposals

  • Batch multiple contract calls

  • Create transaction data for wallets

  • Simulate transactions before signing

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>"
    },
    "name": "evm_encode_function_data"
  }
}

Input Schema

NameRequiredDescriptionDefault
abiYesContract ABI (JSON array)
argsNoFunction arguments (optional)
chainYesEVM chain context
functionNameYesFunction name to encode

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.4/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 disclose meaningful behavior: the selector is auto-prepended, the ABI must match the target function, argument types must be strings, and the return shape is spelled out (encodedData, selector, functionSignature). It stops short of stating whether the tool is a purely local computation or touches the network, and says nothing about error behavior when the ABI does not contain the function.

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 definition occupies about two sentences; the remainder is bulk that does not help an agent call this encoder, including gas-cost commentary, testnet faucet notes, seven-chain block-time trivia, and Linux package-manager advice. These sections bury the actionable rules and inflate the description several times over without adding invocation value.

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 stateless encoding utility the essentials are present: required inputs, output fields, and type pitfalls, which is more than adequate given there is no output schema. Completeness is undercut by the missing differentiation from evm_encode_contract_data and by the irrelevant environment and gas material that displaces genuinely useful context.

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; the description does add useful semantics through worked examples, notably that numeric values must be passed as strings and that order matters. However, it refers to a parameter named 'params' while the schema defines the property as 'args', a naming mismatch that could cause a malformed call despite the otherwise helpful examples.

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 sentence states a specific verb and resource: encode a function call into transaction input data for raw transaction construction. It is clear enough to act on without opening the schema. It does not, however, distinguish itself from the close sibling evm_encode_contract_data, so an agent has no stated basis for choosing between the two.

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 description lists positive use cases (raw transactions, batch operations, multi-sig proposals, pre-signing data), which implies when to reach for it. It never states when NOT to use it or names any alternative tool, leaving the overlap with evm_encode_contract_data and evm_decode_function_result unresolved.

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