x402 Micropayments: HTTP Payment Required
HTTP has a status code that's been unused for decades: 402 Payment Required. EchoRift uses it to enable micropayments without accounts, API keys, or minimums.
The x402 protocol (named after the status code) lets agents pay for services directly via HTTP requests.
The Problem
Traditional payment models require:
- Account creation and verification
- Credit cards or bank accounts
- Minimum balances or commitments
- API keys and authentication
- Billing cycles and invoices
This doesn't work for autonomous agents. Agents can't fill out forms, verify emails, or manage credit cards.
How x402 Works
The x402 protocol is simple:
- Agent makes HTTP request without payment
- Server returns
402 Payment Requiredwith price details - Agent signs USDC payment authorization
- Agent retries request with payment proof
- Server verifies payment, executes request
- Settlement happens on-chain via x402 facilitator
Example Flow
typescript
// First request (no payment)
const response = await fetch('https://blockwire.echorift.xyz/api/feed');
if (response.status === 402) {
// Payment required
const priceInfo = await response.json();
// {
// "price": "0.002",
// "currency": "USDC",
// "paymentAddress": "0x...",
// "nonce": "abc123"
// }
// Sign payment authorization
const paymentAuth = await signPayment({
amount: priceInfo.price,
recipient: priceInfo.paymentAddress,
nonce: priceInfo.nonce,
});
// Retry with payment
const paidResponse = await fetch('https://blockwire.echorift.xyz/api/feed', {
headers: {
'X-402-Payment': paymentAuth,
},
});
// Request succeeds
const events = await paidResponse.json();
}
Why This Works
No accounts: Agents pay per request. No signup, no verification, no accounts to manage.
No minimums: Pay exactly what you use. $0.002 per request, no minimum balance required.
No API keys: Payment authorization is the authentication. If you can pay, you can use the service.
On-chain settlement: Payments settle on Base L2 via the x402 facilitator contract. Transparent, verifiable, trustless.
Dynamic Pricing
Prices can be dynamic based on:
- Operation type: Different operations have different costs
- Complexity: More complex operations cost more
- Volume: High-usage addresses get discounts
- Gas costs: On-chain operations include gas pass-through
The 402 response includes the exact price for that specific request.
Integration with EchoRift Services
All EchoRift services support x402:
- BlockWire: $0.002 per feed request, $0.005 for historical replay
- CronSynth: Free tier + pay-per-trigger for additional schedules
- Switchboard: Free tier + usage-based pricing
- Arbiter: $0.0001-$0.001 for off-chain operations, $0.01-$0.025 + gas for on-chain
Agents pay only for what they use, when they use it.
Why This Matters
x402 enables:
- Agent-native payments: Agents can pay without human intervention
- Granular billing: Pay per operation, not per month
- No lock-in: No accounts means no vendor lock-in
- Transparent costs: Prices are clear before payment
Without x402, agents can't pay for services autonomously. With it, agents can operate independently with economic coordination.
Part of the EchoRift infrastructure series. Learn more about EchoRift architecture.