Skip to main content
Glama

eth_getStorageAt

Retrieve storage values from smart contracts on EVM blockchains by specifying contract address and storage position to access contract state data.

Instructions

Returns the value from a storage position at a given address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesContract address
blockNumberNoBlock number or 'latest', 'earliest', 'pending'latest
positionYesStorage position (hex string)

Implementation Reference

  • The asynchronous handler function for the 'eth_getStorageAt' tool. It makes an RPC call to eth_getStorageAt with the provided address, position, and blockNumber, formats the result, and returns it in the MCP response format. Handles errors by returning an error message.
    async ({ address, position, blockNumber }) => { try { const result = await makeRPCCall("eth_getStorageAt", [ address, position, blockNumber, ]); return { content: [ { type: "text", text: formatResponse( { address, position, value: result, block: blockNumber, }, "Storage Value", ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } },
  • Zod schema defining the input parameters for the eth_getStorageAt tool: address (string), position (string, hex), blockNumber (string, optional, default 'latest').
    { address: z.string().describe("Contract address"), position: z.string().describe("Storage position (hex string)"), blockNumber: z .string() .optional() .default("latest") .describe("Block number or 'latest', 'earliest', 'pending'"), },
  • src/index.ts:670-717 (registration)
    The server.tool() call that registers the 'eth_getStorageAt' tool with the MCP server, including name, description, schema, and handler function.
    server.tool( "eth_getStorageAt", "Returns the value from a storage position at a given address", { address: z.string().describe("Contract address"), position: z.string().describe("Storage position (hex string)"), blockNumber: z .string() .optional() .default("latest") .describe("Block number or 'latest', 'earliest', 'pending'"), }, async ({ address, position, blockNumber }) => { try { const result = await makeRPCCall("eth_getStorageAt", [ address, position, blockNumber, ]); return { content: [ { type: "text", text: formatResponse( { address, position, value: result, block: blockNumber, }, "Storage Value", ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } }, );
  • Generic helper function used by the eth_getStorageAt handler (and others) to make RPC calls to the Ethereum provider.
    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