zap1-x402-demo
v0.1.0
Published
Reference pattern: ZAP1 attestation layer above any x402 payment rail
Downloads
130
Readme
zap1-x402-demo
Reference implementation showing how ZAP1 attestation layers above any x402 payment rail to produce privacy-preserving "proof of paid access" receipts anchored to Zcash.
What this demonstrates
Given an HTTP service returning 402 Payment Required via the x402 protocol and settling through some rail (e.g. CipherPay / Kenbak), the server emits a ZAP1-attestable receipt that:
- is deterministically hashed from
{payment_hash, amount, timestamp, resource_uri} - is submitted as a ZAP1 leaf via
@frontiercompute/zap1-attest - is periodically anchored to Zcash mainnet via a Merkle root transaction
- can be independently verified by the original client (or any third party) later
- reveals no identity linkage (receipt hash only, no client fingerprints)
Files
src/server.js— Express server with x402 middleware + ZAP1 receipt emissionsrc/client.js— demo client that pays the 402, receives the receipt, and later verifies itsrc/receipt_canonicalize.js— deterministic receipt canonicalization (same pattern as hyperdeck trade_attest_hook)
Usage
npm install @frontiercompute/zap1-attest
# (sets ZAP1_API_KEY from https://api.frontiercompute.cash — free trial)
ZAP1_API_KEY=... node src/server.js &
node src/client.js # pays 402, gets receipt, verifies against Zcash anchorArchitecture
[client] --(1) GET /resource-----> [server]
[server] --(2) 402 + x402 instr--> [client]
[client] --(3) pay via x402 rail-> [settlement ] (e.g. CipherPay)
[client] --(4) GET + proof-------> [server]
[server] --(5) emit zap1 leaf----> [api.frontiercompute.cash]
[api] --(6) anchor to zcash--> [zcash mainnet]
[server] --(7) 200 + receipt_id-> [client]
[any later] --(8) verify------------> [api /verify/{leaf}]Steps 3 and 5 are independent — the x402 rail handles settlement, ZAP1 handles the attestation layer above it. A server using this pattern can swap settlement rails (CipherPay, another x402-compatible service) without changing the attestation code.
Status
Reference pattern. Not a deployed service. The primitives (zap1-attest SDK, api.frontiercompute.cash attestation backend) are live and operational. Integration into any specific x402 gateway is a small amount of glue code — this repo shows the glue.
License
MIT.
