The Killer Combo
x402 payments are USDC transfers. Session keys on CHIPI wallets authorize transfers without requiring the owner key each time.| Mode | User Experience |
|---|---|
| Without session | Each payment requires signing (wallet popup / biometrics / PIN) |
| With session | Payments happen automatically — zero interaction per request |
- AI agent autonomous API consumption
- Streaming data feeds (pay-per-query)
- Backend automation (server-to-server payments)
- Mobile apps with “subscribe for X hours” UX
React Implementation
How It Works Under the Hood
- Session creation: Generate a temporary keypair, encrypt private key with user’s PIN
- Session registration: Register the session public key on the wallet contract (one owner signature)
- Session constraint:
allowedEntrypoints: ["transfer"]restricts the session to only USDC transfer calls - x402 payment: When a 402 is received, the hook uses
executeTransactionWithSession()instead ofexecuteTransaction()— the session key signs automatically
Node.js Backend Automation
For server-side automation where you want to consume paid APIs:On-Chain Spending Limits
Session keys alone don’t enforce dollar limits —maxCalls caps the number of transactions, not the amount. For real budget control, use Spending Policies:
Spending policies require CHIPI v33 wallets. See the full guide: Spending Policies.
Three Layers of Protection
| Layer | Scope | Enforced By |
|---|---|---|
maxPaymentAmount (X402Client) | Per-request, client-side | SDK (can be bypassed) |
maxCalls (Session) | Total transaction count | Smart contract |
| Spending Policy | Per-call amount + rolling window total | Smart contract (cannot be bypassed) |
Security Considerations
Session Scope
Always restrict session keys to the minimum required permissions:- Per-request limit:
maxPerCallenforced on-chain ($0.10 per API call) - Session window limit:
maxPerWindowenforced on-chain ($10 per 6 hours) - Transaction count limit:
maxCalls: 100enforced on-chain - Client-side guard:
maxPaymentAmount: "0.10"(early rejection, saves gas)
Session Expiry Fallback
If the session expires during a payment, the hook falls back to requiring the owner’s signature (wallet popup / biometrics / PIN):Best Practices
- Set spending limits: Always configure
maxPaymentAmountand sessionmaxCalls - Whitelist merchants: Use
allowedRecipientswhen possible - Monitor payments: Use
onPaymentCompletecallback for logging/analytics - Short sessions: Prefer shorter session durations with renewal over long-lived sessions
- Transfer-only: Always set
allowedEntrypoints: ["transfer"]for x402 sessions
