Shielded x402 receipt tooling for Zcash machine payments.
This package has two surfaces:
@frontiercompute/zcash-402/zap402: the ZAP-402 library profile: seller guard, buyer paying-fetch, hash-only receipts, selective disclosure, and offline verification.zcash-402: the root MCP server/bin for x402 payment workflows.
ZAP-402 is a profile of ZAP1: a machine-payment receipt is signed, independently verifiable, and shaped to become a ZAP1 leaf. The current build is fixture-settled. It does not claim live shielded settlement, trustless payment proof, or present-tense anchoring.
npm install @frontiercompute/zcash-402import {
createZap402Guard,
createZap402FetchGuard,
createZap402Fetch,
verifyReceiptIntegrity,
} from "@frontiercompute/zcash-402/zap402";Seller, Node HTTP:
const guard = createZap402Guard({ amount_zat: 25_000, resource: "/paid/report" });Seller, Fetch / Cloudflare Worker shape:
const guard = createZap402FetchGuard({ amount_zat: 25_000, resource: "/paid/report" });
const paidReport = guard.protect(async (_request, ctx) => {
return Response.json({ report: "paid report unlocked", receipt: ctx.receipt });
});Buyer:
const f = createZap402Fetch({
pay: async (challenge) => {
// Fixture: simulate a shielded payment.
// Live: send shielded ZEC to challenge.recipient_id once the live scan backend is wired.
},
maxAmountZat: 100_000,
});Verifier:
zap402-verify receipt.json keydir.jsonSee docs/ZAP-402-QUICKSTART.md for the full local seller/buyer/verifier flow, and docs/ZAP-402-CLOUDFLARE.md for the Cloudflare/x402 adoption wedge.
A local Fetch / Cloudflare Worker-shaped demo is included at examples/cloudflare-worker. It exposes /free, /paid/report, and /verify-receipt, writes receipt.json and keydir.json, and runs the verifier CLI.
npm run zap402:demo:cloudflare- x402-style
402 Payment Requiredchallenge andX-PAYMENTretry. - Hash-only
zap1.x402.payment_receiptresponse. - Ed25519 facilitator and merchant signatures.
- Offline receipt verification through
zap402-verify. - Selective auditor disclosure using the per-challenge secret.
- Replay, tamper, underpayment, and double-settle regression coverage.
- Fixture-settled: the current scan backend uses deterministic fixtures behind the same verification predicate.
ZainoScanBackendis the live-node seam and refuses to run without explicit live configuration.- ZAP1 L3 anchoring is designed, not enabled by this package alone.
- Do not call this trustless, formally verified, live-settled, or anchored until those gates are actually met.
npm run build
npm run zap402:test
npm run zap402:smoke
npm pack --dry-runThe production stranger path is: pack/install the package, import @frontiercompute/zcash-402/zap402, and run zap402-verify against a receipt and key directory.
The root zcash-402 bin exposes MCP tools for x402 payment workflows. Those tools require live environment configuration such as ZAP1_API_KEY, ZEC_PAYMENT_ADDRESS, and a Zebra RPC endpoint. The ZAP-402 library quickstart does not require those live credentials.
- ZAP-402 spec: docs/ZAP-402.md
- Cloudflare/x402 product wedge: docs/ZAP-402-CLOUDFLARE.md
- Adoption loop: docs/ZAP-402-ADOPTION.md
- Outreach pack: docs/ZAP-402-OUTREACH.md
- ZAP1: https://github.com/Frontier-Compute/zap1
- Repository: https://github.com/Frontier-Compute/zcash-402
MIT