Skip to content

Repository files navigation

@frontiercompute/zcash-402

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.

Install

npm install @frontiercompute/zcash-402

Library Quickstart

import {
  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.json

See 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.

Adoption Demo

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

What Is Live

  • x402-style 402 Payment Required challenge and X-PAYMENT retry.
  • Hash-only zap1.x402.payment_receipt response.
  • 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.

Boundaries

  • Fixture-settled: the current scan backend uses deterministic fixtures behind the same verification predicate.
  • ZainoScanBackend is 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.

Verify Locally

npm run build
npm run zap402:test
npm run zap402:smoke
npm pack --dry-run

The production stranger path is: pack/install the package, import @frontiercompute/zcash-402/zap402, and run zap402-verify against a receipt and key directory.

MCP Server

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.

Source

License

MIT

About

Shielded x402 payment facilitator for AI agents. MCP server with split-key MPC signing and ZAP1 attestation.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages