zcash_prove_payment
Prove payment inclusion on-chain by fetching a ZAP1 Merkle proof bundle for a leaf hash. Returns leaf, path, root, and anchor.
Instructions
Fetch a ZAP1 Merkle proof bundle for a leaf hash. Returns the full proof: leaf, path, root, and anchor. Use this to prove payment inclusion on-chain.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| leaf_hash | Yes | Hex-encoded leaf hash (64 chars) |
Implementation Reference
- src/tools/receipt.ts:14-42 (handler)Handler function that fetches a ZAP1 Merkle proof bundle from the API for a given leaf hash and returns it as JSON.
async ({ leaf_hash }) => { try { const res = await fetch(`${ZAP1_API}/verify/${leaf_hash}/proof.json`, { signal: AbortSignal.timeout(API_TIMEOUT_MS), }); if (!res.ok) { const text = await res.text(); throw new Error(`${res.status}: ${text}`); } const data = await res.json(); return { content: [ { type: "text" as const, text: JSON.stringify(data, null, 2), }, ], }; } catch (err) { const msg = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${msg}` }], isError: true, }; } } ); - src/tools/receipt.ts:11-13 (schema)Zod schema for the tool input: leaf_hash must be a 64-character hex string.
{ leaf_hash: z.string().regex(/^[0-9a-fA-F]{64}$/, "leaf_hash must be 64-char hex").describe("Hex-encoded leaf hash (64 chars)"), }, - src/tools/receipt.ts:7-43 (registration)Registration of the 'zcash_prove_payment' tool on the MCP server via server.tool().
export function registerReceiptTool(server: McpServer) { server.tool( "zcash_prove_payment", "Fetch a ZAP1 Merkle proof bundle for a leaf hash. Returns the full proof: leaf, path, root, and anchor. Use this to prove payment inclusion on-chain.", { leaf_hash: z.string().regex(/^[0-9a-fA-F]{64}$/, "leaf_hash must be 64-char hex").describe("Hex-encoded leaf hash (64 chars)"), }, async ({ leaf_hash }) => { try { const res = await fetch(`${ZAP1_API}/verify/${leaf_hash}/proof.json`, { signal: AbortSignal.timeout(API_TIMEOUT_MS), }); if (!res.ok) { const text = await res.text(); throw new Error(`${res.status}: ${text}`); } const data = await res.json(); return { content: [ { type: "text" as const, text: JSON.stringify(data, null, 2), }, ], }; } catch (err) { const msg = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${msg}` }], isError: true, }; } } ); }