Protocol Fundamentals

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

REAPP-Augmented x402 Flow on Stellar
Seven steps from request to resource delivery. REAPP adds mandate validation between steps 2 and 4. The resource server sees a standard x402 flow — REAPP's additions are invisible to it.

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.

agent.fetch() — What Developers Write vs What Happens
Nine operations happen invisibly inside agent.fetch(). The developer writes one line. The payment, mandate validation, Soroban enforcement, and audit trail are all transparent.
// 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 data

Why 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.

EVM vs Stellar x402 Feature Comparison
Fee-bump sponsorship is native on Stellar — not a bolt-on meta-transaction hack. Ledger-sequence expiry is more precise than timestamps. SAC eliminates ERC-20 contract overhead entirely.
FeatureEVM x402Stellar x402
Settlement time~12 seconds2–5 seconds
Minimum payment~$0.01 (gas overhead)$0.001
Mainnet feeVariable gas$0.00001 fixed
Fee sponsorshipMeta-transactions (EIP-2771)Fee-bump (native primitive)
Transaction formatEIP-712 typed dataXDR native
Expiry mechanismTimestamp (validBefore)Ledger sequence (precise)
Native stablecoinERC-20 contract requiredUSDC via SAC (native)
Replay protectionNonce-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.

x402stellar → @reapp/sdk Dependency Graph
REAPP wraps x402stellar packages with mandate-awareness. The composition is additive — x402stellar handles settlement, REAPP adds authorization, enforcement, and audit trail.

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).