wait-for-transaction-receipt
Waits for blockchain transaction confirmation and returns the receipt after specified confirmations, enabling reliable transaction status verification.
Instructions
Waits for the transaction to be included on a block, and then returns the transaction receipt.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hash | Yes | The transaction hash to wait for. | |
| confirmations | No | The number of confirmations (blocks that have passed) to wait before resolving. | |
| chainId | No | ID of chain to use when fetching data. |
Implementation Reference
- The execute handler for the 'wait-for-transaction-receipt' tool. It awaits wagmi's waitForTransactionReceipt with the config and args, then returns the JSON-stringified result in MCP content format or the error message on failure.execute: async (args) => { try { const result = await waitForTransactionReceipt(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify(result), }, ], }; } catch (error) { return { content: [ { type: "text", text: (error as Error).message, }, ], }; } },
- Zod schema for the tool's input parameters: hash (TransactionHash), optional confirmations (default 0), optional chainId.parameters: z.object({ hash: TransactionHash.describe("The transaction hash to wait for."), confirmations: z.coerce.number().optional().default(0).describe("The number of confirmations (blocks that have passed) to wait before resolving."), chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), }),
- src/tools/wait-for-transaction-receipt.ts:8-41 (registration)The tool registration function exported from the file, which calls server.addTool to register the tool with name, description, schema, and handler.export function registerWaitForTransactionReceiptTools(server: FastMCP, wagmiConfig: Config): void { server.addTool({ name: "wait-for-transaction-receipt", description: "Waits for the transaction to be included on a block, and then returns the transaction receipt.", parameters: z.object({ hash: TransactionHash.describe("The transaction hash to wait for."), confirmations: z.coerce.number().optional().default(0).describe("The number of confirmations (blocks that have passed) to wait before resolving."), chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), }), execute: async (args) => { try { const result = await waitForTransactionReceipt(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify(result), }, ], }; } catch (error) { return { content: [ { type: "text", text: (error as Error).message, }, ], }; } }, }); };
- src/tools/register-tools.ts:56-56 (registration)Invocation of the tool's registration function within the central registerTools function that sets up all tools on the server.registerWaitForTransactionReceiptTools(server, wagmiConfig);