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:Security Considerations
Session Scope
Always restrict session keys to the minimum required permissions:maxPaymentAmount, this creates a spending cap:
- Per-request limit:
maxPaymentAmount: "0.10"(max $0.10 per API call) - Session limit:
maxCalls: 100(max 100 API calls per session) - Total session spend: max $10.00 over 6 hours
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
