Skip to main content
Glama

get_transaction_receipt

Retrieve transaction details by hash from Ethereum and 30+ compatible networks using the EVM MCP Server, enabling efficient blockchain data access for integrations.

Instructions

Get a transaction receipt by its hash

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkNoNetwork name or chain ID. Defaults to Ethereum mainnet.
txHashYesThe transaction hash to look up

Implementation Reference

  • Full registration of the 'get_transaction_receipt' MCP tool, including input schema, annotations, and inline handler function that uses viem's public client to fetch the transaction receipt.
    server.registerTool(
      "get_transaction_receipt",
      {
        description: "Get transaction receipt (confirmation status, gas used, logs). Use this to check if a transaction has been confirmed.",
        inputSchema: {
          txHash: z.string().describe("Transaction hash (0x...)"),
          network: z.string().optional().describe("Network name or chain ID. Defaults to Ethereum mainnet.")
        },
        annotations: {
          title: "Get Transaction Receipt",
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: true
        }
      },
      async ({ txHash, network = "ethereum" }) => {
        try {
          const client = await services.getPublicClient(network);
          const receipt = await client.getTransactionReceipt({
            hash: txHash as Hash
          });
          return { content: [{ type: "text", text: services.helpers.formatJson(receipt) }] };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error fetching transaction receipt: ${error instanceof Error ? error.message : String(error)}` }],
            isError: true
          };
        }
      }
    );
  • The inline handler function that implements the core logic: fetches public client, calls getTransactionReceipt with the hash, formats the receipt as JSON, and returns it in the MCP response format. Handles errors gracefully.
    async ({ txHash, network = "ethereum" }) => {
      try {
        const client = await services.getPublicClient(network);
        const receipt = await client.getTransactionReceipt({
          hash: txHash as Hash
        });
        return { content: [{ type: "text", text: services.helpers.formatJson(receipt) }] };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Error fetching transaction receipt: ${error instanceof Error ? error.message : String(error)}` }],
          isError: true
        };
      }
    }
  • Tool metadata including description, Zod input schema validating txHash (required string) and network (optional string), and annotations indicating read-only, idempotent behavior.
    {
      description: "Get transaction receipt (confirmation status, gas used, logs). Use this to check if a transaction has been confirmed.",
      inputSchema: {
        txHash: z.string().describe("Transaction hash (0x...)"),
        network: z.string().optional().describe("Network name or chain ID. Defaults to Ethereum mainnet.")
      },
      annotations: {
        title: "Get Transaction Receipt",
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true
      }
    },
  • Helper utility function to get transaction receipt, wrapping viem client call. Not directly used by the tool handler but provides the same functionality.
     * Get a transaction receipt by hash for a specific network
     */
    export async function getTransactionReceipt(hash: Hash, network = 'ethereum'): Promise<TransactionReceipt> {
      const client = getPublicClient(network);
      return await client.getTransactionReceipt({ hash });
    }

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/mcpdotdirect/evm-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server