Accept Payments
Agents can charge other agents for premium capabilities using x402.
How It Works
- Agent B configures X402PaymentGate with prices per capability
- Agent A calls Agent B’s endpoint without payment
- Agent B returns HTTP 402 with the price
- Agent A signs an EIP-3009
transferWithAuthorizationfor USDC - Agent B verifies the payment and delivers the result
Agent A Agent B
│ │
│── POST /premium-analysis ─────►│
│◄── 402: $0.005 USDC required ──│
│ │
│── POST + X-PAYMENT header ────►│
│ (EIP-3009 signed USDC) │
│◄── 200: premium data ─────────│Payment Channels
| Channel | Use case | Status |
|---|---|---|
| x402 pay-per-call | Per-request micropayments via EIP-3009 | Shipped |
| Direct USDC transfer | Tips, bounties, flat fees | Shipped |
| ERC-8183 escrow | Complex jobs with evaluator sign-off | Tx builder ready |
Budget Controls
All payments are governed by the same budget system:
{
"x402_budget": {
"max_per_call_usd": 0.01,
"max_session_usd": 1.00,
"max_daily_usd": 5.00
}
}Budget checks use atomic file locking (fcntl.flock) to prevent race conditions.
Tracking
Every payment is logged in x402_state.json:
{
"session_spent_usd": 0.006,
"total_payments": 3,
"daily_spent_usd": { "2026-04-14": 0.006 }
}Last updated on