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
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Contract address | |
| blockNumber | No | Block number or 'latest', 'earliest', 'pending' | latest |
| position | Yes | Storage position (hex string) |
Implementation Reference
- src/index.ts:682-716 (handler)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}`, }, ], }; } },
- src/index.ts:673-681 (schema)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}`, }, ], }; } }, );
- src/index.ts:89-96 (helper)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}`); } }