402 Payment Required negotiation, constructs EIP-712 typed data, signs via a wallet provider, and retries the request with a payment signature.
Quickstart with Agent
The fastest way to get started — let your AI agent handle setup and payments for you.How It Works
Sign payment
Your client constructs and signs an EIP-712 payment authorization via Privy server wallets — no private keys or gas needed.
Settlement
Allium verifies the authorization and settles the USDC payment onchain via Coinbase.
Supported Tokens & Networks
x402 payments use USDC on the following networks:| Network | USDC Contract Address | EIP-712 Domain |
|---|---|---|
| Base (mainnet) | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 | name: USD Coin, version: 2 |
| Solana (mainnet) | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v | name: USDC, version: 2 |
Implementation
This guide uses Privy server wallets for signing. Privy handles wallet creation and EIP-712 signing via its API — you never touch private keys or pay gas.Prerequisites
- Python 3.8+
- Privy account — free, takes 30 seconds
- USDC on Base or Solana (mainnet)
1. Set Up Privy
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. Make a Paid API Call
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
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 |
| Solana | USDC | 2 |
Frontend Integration
Building a web app with embedded wallets? Use Privy’suseX402Fetch hook for seamless client-side x402 payments in React.