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
| Name | Required | Description | Default |
|---|---|---|---|
| network | No | Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Defaults to Ethereum mainnet. | |
| txHash | Yes | The transaction hash to look up (e.g., '0x1234...') |
Implementation Reference
- src/core/tools.ts:508-518 (handler)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 }; } }
- src/core/tools.ts:494-507 (schema)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 } },
- src/core/tools.ts:492-519 (registration)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 }); }