Client refers to the technical component making an HTTP request, typically the buyer or agent requesting access.Server refers to the component responding to that request, typically the seller or service provider enforcing payment.
Client Role
The client is the initiating entity, an agent, service, or application that requests access to a resource protected by b402. Clients can include:- Autonomous agents operating under an ERC-8004 identity
- Human-operated applications making on-chain payments
- Programmatic services acting on behalf of other systems
Responsibilities
- Initiate requests: Send HTTP requests to b402-enabled endpoints.
- Handle payment requirements: Detect the 402 Payment Requiredresponse and parse its structured payment details.
- Prepare payment payloads: Construct a valid payment payload (e.g., signed permit, transaction hash, or token proof) according to the server’s scheme.
- Resubmit request with proof: Retry the request with an X-PAYMENTheader containing the signed payload or verified transaction reference.
Server Role
The server acts as the service provider, enforcing payment, verification, or identity proof before granting access to its resources. Servers can include:- API endpoints or compute services
- Data or content providers
- Gateways exposing on-chain or off-chain utilities
Responsibilities
- Define payment requirements: Respond to unpaid or unauthorized requests with an HTTP 402 Payment Required, including all required payment details (amount, token, recipient, etc.).
- Verify payment payloads: Validate incoming payments using the b402 facilitator’s /verifyand/settleendpoints or a local verifier.
- Settle transactions: Confirm payment settlement on-chain (typically via USDT or supported EVM-compatible tokens).
- Serve the resource: Once verified, respond with the requested data, API response, or content.
Communication Flow
The typical interaction between a client (agent) and a server (service) in the b402 protocol follows this sequence:- Client initiates request to a b402-enabled endpoint.
- Server responds with 402 Payment Required, including payment details such as amount, token type, and recipient.
- Client prepares a payment payload and submits it on-chain or to a facilitator.
- Server verifies the payment proof through /verify.
- Server settles the transaction via /settleif valid.
- Server returns the requested resource, completing the exchange.