How Payments Work
The x402 protocol
Crumb uses the x402 protocol — an extension of HTTP that adds a native payment layer using the 402 Payment Required status code.
When a client requests a paid resource without a payment header, the server responds with 402 and a PAYMENT-REQUIRED header containing:
- The price (e.g.,
$0.001) - Accepted payment networks (e.g.,
eip155:5042002for Arc Testnet) - The seller's wallet address
- EIP-712 signing parameters
The client then signs a TransferWithAuthorization payload using EIP-712 and retries the request with a Payment-Signature header.
Payment flow
┌─────────┐ ┌──────────┐ ┌─────────────────┐
│ Agent │ │ Provider │ │ Circle Gateway │
│ (Crumb) │ │ (Express)│ │ │
└────┬─────┘ └────┬─────┘ └────────┬────────┘
│ │ │
│ 1. POST /search │ │
│ ─────────────────────────────>│ │
│ │ │
│ 2. 402 Payment Required │ │
│ { price: "$0.001" } │ │
│ <─────────────────────────────│ │
│ │ │
│ 3. Sign EIP-712 payment │ │
│ ──────────────────────────────────────────────────────────────> │
│ │ │
│ 4. Payment verified │ │
│ <──────────────────────────────────────────────────────────────│
│ │ │
│ 5. POST /search │ │
│ + Payment-Signature │ │
│ ─────────────────────────────>│ │
│ │ 6. Verify payment │
│ │ ──────────────────────────────> │
│ │ │
│ │ 7. Payment valid │
│ │ <──────────────────────────────│
│ │ │
│ 8. 200 OK + data │ │
│ <─────────────────────────────│ │
Circle Gateway
Circle Gateway is the settlement layer. It provides:
- Gasless payments — Agents deposit USDC into the Gateway. Payments are signed off-chain using EIP-712 signatures. No ETH needed, no gas fees per call.
- Batched settlement — The Gateway periodically settles transactions on-chain, aggregating many payments into fewer on-chain transactions.
- Cross-chain withdrawals — USDC can be withdrawn from the Gateway to multiple chains: Arc, Base, Ethereum, Avalanche, Solana, Polygon, Arbitrum, Optimism, and more.
EIP-712 signatures
Payments use the EIP-712 TransferWithAuthorization standard. The signed message includes:
| Field | Description |
|---|---|
from | Payer's wallet address |
to | Seller's wallet address |
value | Amount in USDC atomic units (6 decimals) |
validAfter | Timestamp after which the signature is valid |
validBefore | Expiry timestamp |
nonce | Random nonce to prevent replay attacks |
This signature authorizes a USDC transfer without requiring an on-chain transaction from the payer. The Gateway verifies the signature and handles settlement. In the Crumb app, signing is handled by Privy's embedded wallet — the private key is never exposed to the browser.
Deposits and withdrawals
Before making payments, agents deposit USDC into Circle Gateway:
const crumb = new Crumb({ privateKey: '0x...' })
// Deposit USDC into Gateway
await crumb.deposit('10.0')
// Check balance
const balance = await crumb.balance() // "10.0"
// Make payments (deducted from Gateway balance)
await crumb.fetch(url, { maxPayment: 0.01 })
// Withdraw back to wallet or cross-chain
await crumb.withdraw('5.0', { chain: 'baseSepolia' })
Supported chains
| Chain | Status |
|---|---|
| Arc Testnet | Active (development) |
| Base Sepolia | Withdrawals |
| Ethereum Sepolia | Withdrawals |
| Avalanche Fuji | Withdrawals |
| Solana Devnet | Withdrawals |
| Polygon | Withdrawals |
| Arbitrum | Withdrawals |
| Optimism | Withdrawals |
Mainnet support is coming in a future release.