How 402zk Works

Step 1: Requesting a resource

The client sends an HTTP request to a server providing data, an API, or a service.

Step 2: Server returns 402 with payment info

The server responds with HTTP 402 Payment Required and a JSON invoice such as:

{
        "receiver": "SoS..abc",
        "amount": "0.001",
        "ttl": "60s",
        "nonce": "random123"
}

Step 3: Client generates a payment proof

The client (or AI agent) pays the specified amount in stablecoin to the receiver’s address and produces a ZK-SNARK proof showing that the payment occurred—without revealing any sensitive details (e.g., wallet address or exact amount).

Step 4: Client re-requests with proof header

The client resends the original HTTP request, adding a header:

x402-proof: [zk-proof-binary]

Step 5: Server verifies proof and serves resource

The server validates the proof using a ZK verifier. If it’s valid (correct amount, unused nonce, within TTL), the server returns the requested data with HTTP 200 OK.

Last updated