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
| Name | Required | Description | Default |
|---|---|---|---|
| abi | Yes | Contract ABI (JSON array) | |
| args | No | Function arguments (optional) | |
| chain | Yes | EVM chain context | |
| functionName | Yes | Function name to encode |