Skip to main content
Glama

eth_call

Execute smart contract calls without creating blockchain transactions to read data, test functions, or simulate contract interactions on EVM networks.

Instructions

Executes a new message call immediately without creating a transaction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockNumberNoBlock number or 'latest', 'earliest', 'pending'latest
dataYesData to send (hex string)
fromNoFrom address (optional)
gasNoGas limit (optional)
gasPriceNoGas price (optional)
toYesContract address
valueNoValue in wei (optional)

Implementation Reference

  • The handler function for the 'eth_call' tool. It constructs a transaction object from the input parameters and uses the makeRPCCall helper to execute the eth_call RPC method via the ethers provider, then formats and returns the result.
    async ({ to, data, blockNumber, from, value, gas, gasPrice }) => { try { const txObject: any = { to, data, }; if (from) txObject.from = from; if (value) txObject.value = value; if (gas) txObject.gas = gas; if (gasPrice) txObject.gasPrice = gasPrice; const result = await makeRPCCall("eth_call", [txObject, blockNumber]); return { content: [ { type: "text", text: formatResponse( { result, to, data, block: blockNumber, }, "Contract Call Result", ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } },
  • Zod input schema defining the parameters for the eth_call tool: to (required), data (required), and optional blockNumber, from, value, gas, gasPrice.
    { to: z.string().describe("Contract address"), data: z.string().describe("Data to send (hex string)"), blockNumber: z .string() .optional() .default("latest") .describe("Block number or 'latest', 'earliest', 'pending'"), from: z.string().optional().describe("From address (optional)"), value: z.string().optional().describe("Value in wei (optional)"), gas: z.string().optional().describe("Gas limit (optional)"), gasPrice: z.string().optional().describe("Gas price (optional)"), },
  • src/index.ts:432-434 (registration)
    Registration of the 'eth_call' MCP tool using server.tool(name, description, inputSchema, handler).
    server.tool( "eth_call", "Executes a new message call immediately without creating a transaction",
  • Generic helper function that performs RPC calls to the Ethereum provider using ethers.JsonRpcProvider.send(). Directly used by the eth_call handler at line 460.
    async function makeRPCCall(method: string, params: any[] = []): Promise<any> { try { const result = await provider.send(method, params); return result; } catch (error: any) { throw new Error(`RPC call failed: ${error.message}`); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JamesANZ/evm-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server