Skip to main content
x402 is Allium’s micropayment protocol that gives you full control over the payment flow. Your client handles the 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.
1

Install allium-cli

allium-cli is still in early beta.
2

Install agent skills

3

Open your agent

Start Claude Code, Codex, or any compatible AI agent.
4

Ask a question

How It Works

1

Send request

Make a normal API request to any payment-enabled endpoint.
2

Receive 402

The server responds with 402 Payment Required and an accepts array of payment options.
3

Sign payment

Your client constructs and signs an EIP-712 payment authorization via Privy server wallets — no private keys or gas needed.
4

Retry with signature

Resend the original request with the payment signature header attached.
5

Settlement

Allium verifies the authorization and settles the USDC payment onchain via the network’s x402 facilitator — Coinbase for Base, Polygon, and Solana, OKX for X Layer.
6

Get data

Payment confirmed — you receive your data with a 200 response.

Supported Tokens & Networks

x402 payments use USDC on the following networks:

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

1

Create a Privy app

Go to dashboard.privy.io, sign up, and click Create App.
2

Copy your credentials

Copy your App ID and App Secret from the dialog and store them securely.
3

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.
4

Set environment variables

2. Install Dependencies

3. Create a Wallet

Create a server-managed wallet on Privy. This wallet will sign x402 payments on your behalf.
Save the wallet ID as an environment variable:
Fund this wallet address with USDC on Base (or Base Sepolia for testing).
If testing, get free testnet USDC from Circle’s faucet. Select Base Sepolia as the network.

4. Make a Paid API Call

Here’s a complete working example that fetches the current price of ETH. The x402_request helper handles the full payment flow:
  1. Send the API request
  2. Receive a 402 response containing an accepts array of payment options
  3. Select a payment option matching your network (Base or Base Sepolia)
  4. Construct EIP-712 typed data for a USDC TransferWithAuthorization (EIP-3009)
  5. Sign via Privy using eth_signTypedData_v4
  6. Build the x402 v2 PaymentPayload and retry with the PAYMENT-SIGNATURE header
Expected response:

EIP-712 Domain Configuration

The USDC contracts use different EIP-712 domains per network. These values are required when constructing the TransferWithAuthorization typed data for signing. They are provided in the 402 response’s accepts[].extra field.
Privy signs the EIP-712 typed data via eth_signTypedData_v4, but the client must construct the typed data itself from the 402 response fields. The server does not provide a ready-to-sign typed_data object.

Frontend Integration

Building a web app with embedded wallets? Use Privy’s useX402Fetch hook for seamless client-side x402 payments in React.