get_transaction
Retrieve detailed transaction data, including sender, recipient, value, and input data, using the transaction hash and specified blockchain network.
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:449-472 (handler)The MCP tool handler function that executes the get_transaction tool logic. It calls the services.getTransaction helper and returns formatted JSON response or error.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 ${txHash}: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/core/tools.ts:439-448 (schema)Zod input schema defining parameters for the get_transaction tool: txHash (required string) and network (optional string).txHash: z .string() .describe("The transaction hash to look up (e.g., '0x1234...')"), network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Defaults to Ethereum mainnet." ) },
- src/core/tools.ts:436-473 (registration)MCP server.tool registration for the 'get_transaction' tool, including name, description, input schema, and handler function.'get_transaction', 'Get detailed information about a specific transaction by its hash. Includes sender, recipient, value, data, and more.', { txHash: z .string() .describe("The transaction hash to look up (e.g., '0x1234...')"), network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Defaults to Ethereum mainnet." ) }, 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 ${txHash}: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
- Helper service function getTransaction that uses viem public client to fetch transaction details by hash for a given network.export async function getTransaction(hash: Hash, network = 'ethereum') { const client = getPublicClient(network); return await client.getTransaction({ hash }); }
- src/server/server.ts:17-19 (registration)Top-level server setup calls registerEVMTools which includes the get_transaction tool registration.registerEVMResources(server); registerEVMTools(server); registerEVMPrompts(server);