Welcome to the NZRT Wiki Podcast. Today we’re looking at Payment Flow.
Let me walk you through how the x402 payment protocol works from start to finish. It’s a six-step cycle, and once you see the whole picture, it clicks pretty quickly.
Step one: your client makes a plain request to an API endpoint. Think of it like knocking on a door — no money involved yet, just a standard request asking for a resource.
Step two: the server responds with a 402 status code, which means Payment Required. Along with that, the server sends back a response body that tells you exactly what it needs. It includes a version number for the x402 protocol, and a list of accepted payment options. Each option in that list carries several details: a payment scheme, the network to use, a maximum amount required, the specific resource you’re trying to access, a short description, the wallet address to pay, a timeout window in seconds, and the token contract address. There’s also an extra field that names the token — in this case USDC, version 2. One thing worth noting on the amount: it’s expressed in USDC atomic units, which use six decimal places. So a value of one thousand in that field actually equals just one tenth of a cent — about point zero zero one dollars.
Step three: your client creates a payment authorization and signs it. This uses a standard called EIP-712, which is a typed data signing method for Ethereum-compatible wallets. The authorization itself contains a few fields: the payer’s wallet address, the payee’s wallet address, the value being transferred, a valid-after timestamp, a valid-before timestamp, and a random nonce — a one-time value that prevents the same payment from being submitted twice. The client signs all of this with the payer’s private key, producing a cryptographic signature.
Step four: the client retries the original request, this time including that signed payment in a special header. The whole payment payload — which contains the protocol version, the scheme, the network, the signature, and the authorization details — gets encoded and attached to the request. It’s essentially the same knock on the door as before, except now you’re handing over your payment at the same time.
Step five: the resource server doesn’t verify the payment itself. Instead, it forwards the payment payload to a third-party facilitator service. The facilitator checks four things: whether the signature is valid, whether the authorization fields are correct, whether the nonce has already been used, and whether the amount is sufficient. It then responds with either a confirmation that everything checks out, or an error explaining what went wrong.
Step six: if the facilitator gives the green light, the resource server does three things in sequence. First, it calls the facilitator’s settle endpoint, which actually executes the on-chain USDC transfer. Second, it returns the content you originally requested with a 200 OK response. And third, it includes a response header containing the blockchain transaction hash, so you have a receipt for the payment.
Now let’s talk about payment schemes and networks. Currently there is only one supported scheme, called exact. This means you pay a precise USDC amount using a transfer method defined in the EIP-3009 standard. Future versions of the protocol may support streaming micropayments and subscriptions, but for now, exact is the only option in the spec.
For networks, there are two supported options. You have the network identifiers, each pairing a chain with a specific USDC token contract address. The first is Base mainnet, and the second is Base Sepolia, which is the testnet version — useful for development and testing before you go live with real funds.
Finally, a quick note on caching. Clients are allowed to cache payment authorizations for the same resource, as long as you’re still within the valid-before time window. However, each authorization is strictly single-use. The nonce mechanism ensures that once a payment has been settled on-chain, it cannot be replayed. So caching helps you avoid redundant signing, but you can never reuse a nonce that’s already been spent.
That’s it for this episode of the NZRT Wiki Podcast. Thanks for listening.