get_transaction_receipt
Retrieve transaction confirmation status, gas usage details, and event logs from EVM-compatible blockchains to verify transaction completion.
Instructions
Get transaction receipt (confirmation status, gas used, logs). Use this to check if a transaction has been confirmed.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| txHash | Yes | Transaction hash (0x...) | |
| network | No | Network name or chain ID. Defaults to Ethereum mainnet. |
Implementation Reference
- src/core/tools.ts:486-512 (handler)MCP tool handler: fetches transaction receipt via service, formats as JSON text content, handles errors with isError flag.async ({ txHash, network = 'ethereum' }) => { try { const receipt = await services.getTransactionReceipt( txHash as Hash, network ); return { content: [ { type: 'text', text: services.helpers.formatJson(receipt) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching transaction receipt ${txHash}: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/core/tools.ts:479-484 (schema)Zod input schema: txHash (string, required), network (string, optional).{ txHash: z.string().describe('The transaction hash to look up'), network: z .string() .optional() .describe('Network name or chain ID. Defaults to Ethereum mainnet.')
- src/core/tools.ts:475-513 (registration)Tool registration via server.tool call in registerEVMTools, including name, description, schema, and handler.// Get transaction receipt server.tool( 'get_transaction_receipt', 'Get a transaction receipt by its hash', { txHash: z.string().describe('The transaction hash to look up'), network: z .string() .optional() .describe('Network name or chain ID. Defaults to Ethereum mainnet.') }, async ({ txHash, network = 'ethereum' }) => { try { const receipt = await services.getTransactionReceipt( txHash as Hash, network ); return { content: [ { type: 'text', text: services.helpers.formatJson(receipt) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching transaction receipt ${txHash}: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
- Underlying service function that uses viem's public client to fetch the transaction receipt from the blockchain.export async function getTransactionReceipt(hash: Hash, network = 'ethereum'): Promise<TransactionReceipt> { const client = getPublicClient(network); return await client.getTransactionReceipt({ hash }); }