Architecture & Flow
Below is a high-level description of how our extended x402 flow works:
The user connects their wallet (smart contract wallet supporting ERC-4337) and requests access to x402-protected content.
The server responds with HTTP 402 and includes in the response the payment requirements: network (chain), recipient address, payment amount, possibly token address, etc.
The client builds a UserOperation: the target callData is to effect the desired payment (e.g., transfer of ERC-20 token or other contract call) from the user’s smart wallet.
The user signs the UserOperation and sends it to the server (or the server provides a link or widget for submission).
The server forwards the signed UserOperation to the facilitator service.
The facilitator verifies the UserOperation (signature, nonce, correct target, payment amount, token, chain) and simulates it via dry-run to ensure it will succeed on-chain.
If validation passes, the server triggers the facilitator to settle the payment: the UserOperation is submitted to the chain (via bundler/entrypoint) and the facilitator monitors the transaction until confirmed.
Once settlement is complete and confirmed, the server returns the protected content to the user, granting access.
Components
Server (Resource Provider): hosts content or API behind x402. Responds with HTTP 402 payment requirement, receives signed UserOperation, forwards it to facilitator, waits for confirmation, then delivers content.
Client SDK: runs in browser/app. Reads the HTTP 402 response, builds user-friendly UI showing payment details, interacts with user wallet (smart-wallet) to construct and sign UserOperation, and sends signed payload back.
Facilitator Service: This is a trusted back-end (ideally TEE-backed for integrity) that:
Accepts signed UserOperations (opaque bytes)
Validates signature, target callData, payment details
Simulates the UserOperation on respective chain to ensure success
Submits to bundler/entrypoint and tracks the resulting transaction until confirmed
Notifies server of success or failure
Smart Wallet / User’s Account Abstraction Setup: The user holds a wallet contract (smart account) that supports ERC-4337 operations; the SDK helps prepare the UserOperation struct.
Last updated