Introducion
The x402 protocol introduces the Facilitator, an optional service designed to streamline payment processing for sellers. Its primary goal is to simplify how sellers validate payment credentials from buyers and settle transactions.
A Facilitator's core duties include:
- Payment Verification: Confirming the validity of a buyer's submitted payment.
- Payment Settlement: Executing the payment settlement on the blockchain network for the seller.
- Result Reporting: Communicating the outcome of the verification and settlement back to the server, which then determines whether to grant the client's request.
Leveraging a Facilitator abstracts away the complexities of the blockchain. Sellers are freed from the need to run their own nodes or develop bespoke payment validation systems, leading to a simpler integration process and ensuring that transactions are verified accurately and in real time.
The x402 protocol relies on EIP-3009. EIP-3009 is an extension of the ERC20 standard, with its core feature being transferWithAuthorization. This function allows User A (Buyer) to sign a transfer transaction off-chain (the payload includes from, to, value, an expiration time, and a random nonce). This payload and its signature are then sent to User B (Seller) off-chain. User B can then submit this to the blockchain to execute the ERC20 transfer, bearing all the gas fees in this scenario.
The x402 protocol flow is as follows:
- The buyer sends an initial request to the seller. The seller responds with an
HTTP 402 Payment Requiredstatus code, along with a PaymentRequirements object (containing the stablecoin address, settlement network, required amount, and recipient address). - The buyer signs a transaction based on the
PaymentRequirementsand sends the resulting signature to the seller. - The seller verifies the signature with a Facilitator. Upon successful verification, the seller processes the original request. After processing, the seller instructs the Facilitator to execute the on-chain settlement and, based on the settlement result, determines whether to deliver the final response to the buyer.
Updated about 8 hours ago
