getTransactionCount
Retrieve the total number of transactions sent from a specific Ethereum wallet address to analyze account activity and usage patterns.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes |
Implementation Reference
- tools/balance.js:31-42 (handler)The handler function that executes the getTransactionCount tool logic. It takes an Ethereum address, fetches the transaction count (nonce) using web3.eth.getTransactionCount, and returns a formatted text response or error.async ({ address }) => { try { const transactionCount = await web3.eth.getTransactionCount(address); return { content: [{ type: "text", text: `Transaction count (nonce) for ${address}: ${transactionCount}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error fetching transaction count: ${error.message}` }] }; } }
- tools/balance.js:30-30 (schema)Zod schema defining the input parameter: an Ethereum address validated with regex.{ address: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address") },
- tools/balance.js:29-43 (registration)The server.tool call that registers the getTransactionCount tool with the MCP server, specifying the name, input schema, and handler function.server.tool("getTransactionCount", { address: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address") }, async ({ address }) => { try { const transactionCount = await web3.eth.getTransactionCount(address); return { content: [{ type: "text", text: `Transaction count (nonce) for ${address}: ${transactionCount}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error fetching transaction count: ${error.message}` }] }; } } );
- main.js:60-60 (registration)Invocation of registerBalanceTools which includes the registration of getTransactionCount among other balance tools.registerBalanceTools(server, web3);