wait-for-transaction-receipt
Monitors blockchain transactions, waits for inclusion in a block, and returns the receipt once confirmed. Input transaction hash and optional confirmations to track progress securely.
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 |
|---|---|---|---|
| chainId | No | ID of chain to use when fetching data. | |
| confirmations | No | The number of confirmations (blocks that have passed) to wait before resolving. | |
| hash | Yes | The transaction hash to wait for. |
Implementation Reference
- The execute function that calls waitForTransactionReceipt from wagmi/core with the provided arguments, handles the result by stringifying it as JSON in a text content response, or returns 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 defining the input parameters: hash (TransactionHash, required), confirmations (optional number, default 0), chainId (optional number).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:9-40 (registration)The server.addTool call that registers the 'wait-for-transaction-receipt' tool, including name, description, parameters schema, and execute handler.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)The top-level call to registerWaitForTransactionReceiptTools during the overall registration of all tools.registerWaitForTransactionReceiptTools(server, wagmiConfig);