Specification, not yet live. The packages and endpoints below are planned names; they aren’t published yet. Code here is an outline of the intended interface.
The proposed x402 integration returns a payment challenge, accepts a payment proof and grants access. The proposed x402 integration returns a payment challenge, accepts a payment proof and grants access.

Packages

1. Client setup

client/numpayZKClient.ts

2. Generate a private payment proof

client/generateProof.ts

3. Protect an API with x402 middleware

When a request has no valid x-payment-proof header, the middleware answers 402:
With a proof present, the middleware checks:
  • the proof is valid;
  • the amount is within range (10% tolerance);
  • the recipient matches the merchant;
  • the proof is less than 5 minutes old.

4. Example server

server/app.ts
Environment: MERCHANT_PHONE, MERCHANT_WALLET, PORT.

5. Client that pays automatically

X402ZKPaymentClient.makePrivateRequest(endpoint, options):
  1. Calls the endpoint.
  2. On 402, generates a proof.
  3. POST /verify, then POST /settle.
  4. Retries the original request with X-Payment-Proof.
sendPrivatePayment(recipientPhone, amount, memo?) sends a private payment without an API call.