Skip to main content
Glama

get_transaction

Retrieve detailed transaction data, including sender, recipient, value, and more, by inputting a transaction hash. Works across multiple Ethereum-compatible networks via EVM MCP Server.

Instructions

Get detailed information about a specific transaction by its hash. Includes sender, recipient, value, data, and more.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkNoNetwork name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Defaults to Ethereum mainnet.
txHashYesThe transaction hash to look up (e.g., '0x1234...')

Implementation Reference

  • The async handler function that implements the 'get_transaction' tool. It takes txHash and optional network, fetches the transaction using services.getTransaction, formats it as JSON, and returns it in the MCP response format. Handles errors gracefully.
    async ({ txHash, network = "ethereum" }) => { try { const tx = await services.getTransaction(txHash as Hash, network); return { content: [{ type: "text", text: services.helpers.formatJson(tx) }] }; } catch (error) { return { content: [{ type: "text", text: `Error fetching transaction: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
  • The tool schema defining input parameters (txHash required, network optional), description, and annotations indicating it's read-only and idempotent.
    { description: "Get transaction details by transaction hash", 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", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true } },
  • The MCP server.registerTool call that registers the 'get_transaction' tool, specifying its name, schema, and handler function within the registerEVMTools function.
    server.registerTool( "get_transaction", { description: "Get transaction details by transaction hash", 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", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true } }, async ({ txHash, network = "ethereum" }) => { try { const tx = await services.getTransaction(txHash as Hash, network); return { content: [{ type: "text", text: services.helpers.formatJson(tx) }] }; } catch (error) { return { content: [{ type: "text", text: `Error fetching transaction: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
  • Supporting helper function from services that performs the actual RPC call to retrieve transaction details using viem's PublicClient.
    export async function getTransaction(hash: Hash, network = 'ethereum') { const client = getPublicClient(network); return await client.getTransaction({ 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