eth_getTransactionReceipt
Retrieve transaction receipt details including status, gas used, and logs to verify transaction execution and outcomes on EVM-compatible blockchains.
Instructions
Returns the receipt of a transaction by transaction hash
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| txHash | Yes | Transaction hash |
Implementation Reference
- src/index.ts:391-430 (handler)The complete server.tool registration which defines the handler function for the 'eth_getTransactionReceipt' tool. The handler takes a txHash, calls the RPC method via makeRPCCall, formats the response using formatResponse, and handles errors.server.tool( "eth_getTransactionReceipt", "Returns the receipt of a transaction by transaction hash", { txHash: z.string().describe("Transaction hash"), }, async ({ txHash }) => { try { const result = await makeRPCCall("eth_getTransactionReceipt", [txHash]); if (!result) { return { content: [ { type: "text", text: `Transaction receipt not found: ${txHash}`, }, ], }; } return { content: [ { type: "text", text: formatResponse(result, "Transaction Receipt"), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } }, );
- src/index.ts:394-396 (schema)Input schema for the tool, defining 'txHash' as a required string parameter.{ txHash: z.string().describe("Transaction hash"), },
- src/index.ts:89-96 (helper)Shared helper function makeRPCCall used by the eth_getTransactionReceipt handler to perform the actual RPC call to the Ethereum provider.async function makeRPCCall(method: string, params: any[] = []): Promise<any> { try { const result = await provider.send(method, params); return result; } catch (error: any) { throw new Error(`RPC call failed: ${error.message}`); } }
- src/index.ts:32-86 (helper)Shared helper function formatResponse used to format the tool output in markdown.function formatResponse(data: any, title: string): string { let result = `**${title}**\n\n`; if (typeof data === "object" && data !== null) { if (Array.isArray(data)) { // Handle arrays result += `**Count:** ${data.length}\n\n`; data.forEach((item, index) => { result += `**${index + 1}.**\n`; if (typeof item === "object" && item !== null) { result += formatObject(item, " "); } else { result += ` ${item}\n`; } result += "\n"; }); } else { // Handle objects result += formatObject(data, ""); } } else { result += `${data}\n`; } return result; } // Helper function to format objects recursively function formatObject(obj: any, indent: string): string { let result = ""; for (const [key, value] of Object.entries(obj)) { if (typeof value === "object" && value !== null) { if (Array.isArray(value)) { result += `${indent}**${key}:** [${value.length} items]\n`; if (value.length > 0 && value.length <= 10) { value.forEach((item, index) => { if (typeof item === "object" && item !== null) { result += `${indent} ${index}: ${JSON.stringify(item, null, 2).replace(/\n/g, "\n" + indent + " ")}\n`; } else { result += `${indent} ${index}: ${item}\n`; } }); } } else { result += `${indent}**${key}:**\n`; result += formatObject(value, indent + " "); } } else { result += `${indent}**${key}:** ${value}\n`; } } return result; }