x402 HTTP Payment Protocol
x402 repurposes HTTP's dormant 402 Payment Required status code for machine-to-machine payments. An agent hits an endpoint, gets told what it costs, pays, gets the resource. All automated — invisible to the developer.
What x402 Actually Is
The HTTP 402 status code has existed since 1991, reserved for "Payment Required" but never formally implemented. x402 activates it as a machine-to-machine payment standard: a resource server emits a 402 response with structured payment details, the client constructs and signs a payment payload, retries the request, and the facilitator verifies and settles on-chain.
The key developer-facing insight: agent.fetch() handles all of this transparently. From a developer's perspective it looks identical to a normal fetch call — the entire payment layer is invisible. REAPP intercepts the flow at step 3 to inject mandate validation before any signing happens.
The 7-Step Flow on Stellar
Developer Transparency
The entire 7-step flow is abstracted behind a single function call. This is the core DX principle — agents should be able to pay for resources with the same ergonomics as fetching them.
// This is ALL the developer writes:
const data = await agent.fetch('https://api.dataservice.com/premium/report');
// agent.fetch() internally handles:
// 1. Initial request → receives 402
// 2. AP2 mandate validation against payment details
// 3. Soroban spending limit check
// 4. XDR transaction construction + agent signing
// 5. Facilitator verification
// 6. Retry with X-PAYMENT header
// 7. Stellar settlement (~3 seconds)
// 8. Audit trail recording on-chain
// 9. Returns response dataWhy Stellar Beats EVM for Agent Payments
Stellar's native advantages over EVM x402 directly enable the micropayment economics required for agentic commerce. The numbers matter at scale: an agent making 100 API calls per day at $0.001 each spends $0.10 — the same workflow on Ethereum at $0.01 minimum costs $1.00, ten times more.
| Feature | EVM x402 | Stellar x402 |
|---|---|---|
| Settlement time | ~12 seconds | 2–5 seconds |
| Minimum payment | ~$0.01 (gas overhead) | $0.001 |
| Mainnet fee | Variable gas | $0.00001 fixed |
| Fee sponsorship | Meta-transactions (EIP-2771) | Fee-bump (native primitive) |
| Transaction format | EIP-712 typed data | XDR native |
| Expiry mechanism | Timestamp (validBefore) | Ledger sequence (precise) |
| Native stablecoin | ERC-20 contract required | USDC via SAC (native) |
| Replay protection | Nonce-based (stateful) | Sequence numbers (protocol-level) |
x402stellar Package Architecture
x402stellar is a four-package open-source ecosystem. REAPP builds directly on all four packages, adding the AP2 mandate layer and Soroban policy enforcement without modifying the underlying x402 protocol. x402stellar is a dependency, not a competitor.
Facilitator Trust Model
The facilitator is a non-custodial service that verifies payment signatures and submits transactions to the blockchain. REAPP treats it as part of the threat surface — the SDK is facilitator-agnostic. Two production options exist:
- Coinbase facilitator — testnet support with sponsored fees. Not the primary mainnet path.
- OpenZeppelin Relayer-based facilitator — exposes
/verify,/settle,/supported. Available testnet and mainnet. This is REAPP's recommended production path.
Fee sponsorship via LaunchTube is configurable per deployment — not a hard dependency on any single sponsorship service. If LaunchTube is unavailable, agents pay standard Stellar fees ($0.00001 per operation).