Skip to main content
Glama

eth_getTransactionByHash

Retrieve detailed transaction information from EVM-compatible blockchains using a transaction hash to analyze transaction data, status, and blockchain activity.

Instructions

Returns the information about a transaction requested by transaction hash

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
txHashYesTransaction hash

Implementation Reference

  • Handler function that takes txHash, calls makeRPCCall to fetch transaction data via RPC, handles not found case, formats response using formatResponse, and returns error if failed.
    async ({ txHash }) => {
      try {
        const result = await makeRPCCall("eth_getTransactionByHash", [txHash]);
        if (!result) {
          return {
            content: [
              {
                type: "text",
                text: `Transaction not found: ${txHash}`,
              },
            ],
          };
        }
    
        return {
          content: [
            {
              type: "text",
              text: formatResponse(result, "Transaction Information"),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: `Error: ${error.message}`,
            },
          ],
        };
      }
    },
  • Input schema validation using Zod: requires txHash as string.
    {
      txHash: z.string().describe("Transaction hash"),
    },
  • src/index.ts:350-389 (registration)
    Registration of the tool with MCP server using server.tool(name, description, schema, handler).
    server.tool(
      "eth_getTransactionByHash",
      "Returns the information about a transaction requested by transaction hash",
      {
        txHash: z.string().describe("Transaction hash"),
      },
      async ({ txHash }) => {
        try {
          const result = await makeRPCCall("eth_getTransactionByHash", [txHash]);
          if (!result) {
            return {
              content: [
                {
                  type: "text",
                  text: `Transaction not found: ${txHash}`,
                },
              ],
            };
          }
    
          return {
            content: [
              {
                type: "text",
                text: formatResponse(result, "Transaction Information"),
              },
            ],
          };
        } catch (error: any) {
          return {
            content: [
              {
                type: "text",
                text: `Error: ${error.message}`,
              },
            ],
          };
        }
      },
    );
  • Helper function used by the handler to perform the actual RPC call 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}`);
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it 'Returns the information about a transaction', which implies a read-only operation, but doesn't specify what information is included (e.g., sender, receiver, gas, status), whether it's real-time or historical, error conditions (e.g., invalid hash), or performance aspects like rate limits. For a tool with zero annotation coverage, this is a significant gap in behavioral context.

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, efficient sentence that directly states the tool's purpose without any fluff. It's front-loaded with the core action and resource, making it easy to parse. Every word earns its place, and there's no redundancy or 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 the tool's complexity (querying blockchain transactions), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what information is returned (e.g., transaction details like from, to, value), potential errors, or behavioral traits. For a tool in this context, more detail is needed to fully guide an AI agent, especially without structured output data.

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?

The input schema has 100% description coverage, with the parameter 'txHash' documented as 'Transaction hash'. The description adds no additional meaning beyond this, as it only repeats 'transaction hash' without elaborating on format (e.g., hex string, length) or constraints. With high schema coverage, the baseline is 3, and the description doesn't compensate with extra details.

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

Purpose4/5

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

The description clearly states the action ('Returns the information about a transaction') and the resource ('transaction'), specifying it's requested by 'transaction hash'. It distinguishes from siblings like eth_getTransactionReceipt (which returns receipt data) and eth_getTransactionCount (which counts transactions), though not explicitly. However, it doesn't fully differentiate from all siblings (e.g., eth_getBlockByNumber also returns transaction info within blocks), so it's not a perfect 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose it over eth_getTransactionReceipt (for receipt data) or eth_getBlockByNumber (for block-level transaction details), nor does it specify prerequisites like needing a valid hash. Usage is implied by the name and description alone, with no explicit context or exclusions.

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