wait-for-transaction-receipt
Wait for a blockchain transaction to be included in a block and return its receipt. Requires transaction hash and chain ID as inputs. Facilitates secure blockchain interactions via MCPilot's MetaMask integration.
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 | ||
| hash | Yes |
Implementation Reference
- The execution handler for the 'wait-for-transaction-receipt' tool. It uses wagmi's waitForTransactionReceipt to fetch the receipt and returns it as text content, or error message.execute: async (args) => { try { const hash = args.hash as Address const chainId = args.chainId as typeof wagmiConfig['chains'][number]['id'] const result = await waitForTransactionReceipt(wagmiConfig, { hash, chainId, }) return { content: [ { type: "text", text: JSONStringify(result), }, ], } } catch (error) { return { content: [ { type: "text", text: (error as Error).message, }, ], } } },
- Zod schema defining the input parameters: transaction hash (required string) and optional chainId (number).parameters: z.object({ hash: z.string(), chainId: z.coerce.number().optional(), }),
- The registration function that defines the tool (name, description, schema, handler) and adds it to the FastMCP server.export function registerWaitForTransactionReceiptTools(server: FastMCP): 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: z.string(), chainId: z.coerce.number().optional(), }), execute: async (args) => { try { const hash = args.hash as Address const chainId = args.chainId as typeof wagmiConfig['chains'][number]['id'] const result = await waitForTransactionReceipt(wagmiConfig, { hash, chainId, }) return { content: [ { type: "text", text: JSONStringify(result), }, ], } } catch (error) { return { content: [ { type: "text", text: (error as Error).message, }, ], } } }, }); };
- packages/metamask-mcp/src/index.ts:59-59 (registration)The call to register the 'wait-for-transaction-receipt' tool during MCP server setup.registerWaitForTransactionReceiptTools(server);
- packages/metamask-mcp/src/tools/index.ts:22-22 (registration)Re-exports the register function from the tool file for use in main index.ts.export * from "./wait-for-transaction-receipt.js";