This guide uses Privy server wallets for signing x402 payments. Privy handles wallet creation and EIP-712 signing via its API — you never touch private keys or pay gas. You sign payment authorizations with Privy’s
eth_signTypedData_v4 RPC method, and Allium handles onchain USDC settlement.Prerequisites
- Python 3.8+
- Privy account — free, takes 30 seconds
- USDC on Base (mainnet) or Base Sepolia (testnet)
1. Set Up Privy
Privy manages your wallet and handles EIP-712 signing — no private keys to manage.Create a Privy app
Go to dashboard.privy.io, sign up, and click Create App.
If you closed the dialog too soon
Go to Configuration → App settings → Basics → New Secret to generate a new App ID and App Secret pair.
2. Install Dependencies
3. Create a Wallet
Create a server-managed wallet on Privy. This wallet will sign x402 payments on your behalf.4. Get a Token Price
Here’s a complete working example that fetches the current price of ETH. Thex402_request helper handles the full payment flow:
- Send the API request
- Receive a 402 response containing an
acceptsarray of payment options - Select a payment option matching your network (Base or Base Sepolia)
- Construct EIP-712 typed data for a USDC
TransferWithAuthorization(EIP-3009) - Sign via Privy using
eth_signTypedData_v4 - Build the x402 v2
PaymentPayloadand retry with thePAYMENT-SIGNATUREheader
Token Support
Payment Token
x402 payments use USDC exclusively. Payments are gasless — Allium handles onchain settlement so you only need USDC, not ETH.| Network | USDC Address | Use For |
|---|---|---|
| Base | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 | Production |
| Base Sepolia | 0x036CbD53842c5426634e7929541eC2318f3dCF7e | Testing |
EIP-712 Domain Configuration
The USDC contracts use different EIP-712 domains per network. These values are required when constructing theTransferWithAuthorization typed data for signing. They are provided in the 402 response’s accepts[].extra field.
| Network | Domain Name | Version |
|---|---|---|
| Base | USD Coin | 2 |
| Base Sepolia | USDC | 2 |
Frontend Integration
Building a web app with embedded wallets? Use Privy’suseX402Fetch hook for seamless client-side x402 payments in React.