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}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool returns a count but does not disclose behavioral traits such as whether it requires authentication, rate limits, error conditions, or the format of the returned value (e.g., integer, hex). For a tool with no annotation coverage, this leaves significant gaps in understanding its operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, direct sentence with no wasted words, front-loading the core purpose. It is appropriately sized for a simple query tool and efficiently communicates the essential function without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It lacks details on return value format, error handling, or behavioral constraints, which are crucial for a tool that interacts with blockchain data. The description alone does not provide enough context for reliable agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters (address and blockNumber). The description does not add any meaning beyond what the schema provides, such as explaining parameter interactions or edge cases. Baseline 3 is appropriate as the schema handles parameter documentation adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Returns the number of transactions sent') and the target resource ('from an address'), distinguishing it from siblings like eth_getBalance (returns balance) or eth_getTransactionByHash (returns transaction details). It uses precise terminology that matches the tool's name and domain.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for checking transaction counts from addresses, but provides no explicit guidance on when to use this tool versus alternatives like eth_getTransactionByHash (for specific transaction details) or eth_getLogs (for event logs). It lacks context on prerequisites or exclusions, leaving usage inferred rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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