Architecture
System architecture and component overview of OpenX402
System Overview
┌──────────┐ ┌──────────┐ ┌─────────────┐ ┌──────────────┐
│ Client │────▶│ Server │────▶│ Facilitator │────▶│ Chain │
│(x402-fetch)│◀───│(middleware)│◀───│ (OpenX402) │◀───│(Base/Mon/Sol)│
└──────────┘ └──────────┘ └─────────────┘ └──────────────┘Components
Client (x402-fetch)
The client library wraps the standard fetch API. When it receives a 402 Payment Required response, it:
- Parses the payment requirements from the response headers
- Signs a payment authorization using the client's private key
- Retries the request with payment headers
EVM (Base): Signs an EIP-3009 transferWithAuthorization — the client never sends a transaction, only signs an authorization that the facilitator later executes on-chain.
Solana: Builds and signs an SPL Token TransferChecked instruction. The facilitator acts as fee payer and submits the transaction.
Server (x402 Middleware)
The server uses x402-express, x402-hono, or similar middleware to protect routes. The middleware:
- Checks incoming requests for payment headers
- If no payment is present, returns
402 Payment Requiredwith payment requirements - If payment headers are present, forwards them to the facilitator's
/verifyendpoint - On successful verification, allows the request through to the route handler
- After serving the response, calls the facilitator's
/settleendpoint to execute the payment
Facilitator (OpenX402)
The facilitator is the core of the system. It is served from a globally distributed edge network across 300+ locations at facilitator.openx402.ai for lower latency to your server. It handles:
- Verification — validates that the signed authorization matches the payment requirements (correct amount, recipient, asset, non-expired, valid signature)
- Settlement — executes
transferWithAuthorizationon the USDC contract (EVM) or submits the signed SPL transaction (Solana) - Nonce Management — tracks used nonces in a durable store to prevent replay attacks
- Rate Limiting — prevents abuse (10 settle requests per minute per payer)
- Discovery — optional extension for sellers to register their resources
- Whitelist — payment receiver addresses must be registered
Settlement Index
OpenX402 indexes successful settlements directly inside the facilitator edge runtime. There is no separate always-on indexer service required for scanner data.
Indexed chains:
- Base — settlement records written at settle-time
- Monad — settlement records written at settle-time
- Solana — settlement records written at settle-time
Scanner
The web frontend at openx402.ai provides a real-time view of x402 transactions across chains, powered by the facilitator's built-in settlement index.
Payment Flow (Detailed)
Client Server Facilitator Chain
│ │ │ │
│ GET /resource │ │ │
│─────────────────────▶│ │ │
│ │ │ │
│ 402 + requirements │ │ │
│◀─────────────────────│ │ │
│ │ │ │
│ Sign authorization │ │ │
│ (local, no tx) │ │ │
│ │ │ │
│ GET /resource │ │ │
│ + payment headers │ │ │
│─────────────────────▶│ │ │
│ │ POST /verify │ │
│ │──────────────────────▶│ │
│ │ { isValid: true } │ │
│ │◀──────────────────────│ │
│ │ │ │
│ 200 + resource │ │ │
│◀─────────────────────│ │ │
│ │ POST /settle │ │
│ │──────────────────────▶│ │
│ │ │ transferWith │
│ │ │ Authorization() │
│ │ │──────────────────▶│
│ │ │ tx confirmed │
│ │ │◀──────────────────│
│ │ { success, txHash } │ │
│ │◀──────────────────────│ │Supported Networks
| Network | ID | Asset | Method |
|---|---|---|---|
| Base | eip155:8453 | USDC | EIP-3009 |
| Monad | eip155:143 | USDC | EIP-3009 |
| Base Sepolia | eip155:84532 | USDC | EIP-3009 |
| Solana | solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp | USDC | SPL TransferChecked |
Security Model
- The client's private key only signs authorizations — it never sends transactions (on EVM; on Solana the facilitator submits)
- The facilitator's private key is a hot wallet that pays gas and executes settlements
- Funds flow directly from payer to recipient — the facilitator never custodies funds
- Nonces are tracked in a durable nonce store to prevent replay attacks
- Signature verification happens off-chain before settlement to avoid wasting gas on invalid payments
- Whitelist ensures only registered receivers can accept payments