Skip to main content
Glama

eth_getTransactionCount

Check how many transactions an Ethereum address has sent to determine account activity and calculate nonce values for new transactions.

Instructions

Returns the number of transactions sent from an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesAddress to check transaction count for
blockNumberNoBlock number or 'latest', 'earliest', 'pending'latest

Implementation Reference

  • src/index.ts:241-286 (registration)
    Registration of the 'eth_getTransactionCount' tool using server.tool, which includes the name, description, input schema, and handler function.
    server.tool( "eth_getTransactionCount", "Returns the number of transactions sent from an address", { address: z.string().describe("Address to check transaction count for"), blockNumber: z .string() .optional() .default("latest") .describe("Block number or 'latest', 'earliest', 'pending'"), }, async ({ address, blockNumber }) => { try { const result = await makeRPCCall("eth_getTransactionCount", [ address, blockNumber, ]); const nonce = parseInt(result, 16); return { content: [ { type: "text", text: formatResponse( { address, nonce_hex: result, nonce_decimal: nonce, block: blockNumber, }, "Transaction Count (Nonce)", ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } }, );
  • Handler function that executes the eth_getTransactionCount RPC call via makeRPCCall, parses the nonce, formats the response using formatResponse, and handles errors.
    async ({ address, blockNumber }) => { try { const result = await makeRPCCall("eth_getTransactionCount", [ address, blockNumber, ]); const nonce = parseInt(result, 16); return { content: [ { type: "text", text: formatResponse( { address, nonce_hex: result, nonce_decimal: nonce, block: blockNumber, }, "Transaction Count (Nonce)", ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } },
  • Zod schema defining input parameters: required 'address' string and optional 'blockNumber' string defaulting to 'latest'.
    { address: z.string().describe("Address to check transaction count for"), blockNumber: z .string() .optional() .default("latest") .describe("Block number or 'latest', 'earliest', 'pending'"), },
  • Helper function that performs generic RPC calls using the ethers provider, used by the handler.
    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