xclaw02Make x402 payments. Pay for APIs, sell your services, handle 402 Payment Required responses with USDC on Base and other EVM chains.
Install via ClawdBot CLI:
clawdbot install primer-dev/xclaw02Your entry point into x402 - the open payment standard for the agentic web.
x402 is an open protocol enabling instant stablecoin payments over HTTP using the 402 Payment Required status code. xClaw02, built by Primer, provides agent-friendly CLI tools and simple APIs for making and receiving payments.
Use xClaw02 when:
| User Says/Asks | What to Do |
|----------------|------------|
| "I got a 402 error" | This is an x402 payment request. Probe the URL with xclaw02 probe , show the price, ask if they want to pay |
| "Pay for this API" | Use xclaw02 pay - always confirm amount with user first |
| "Check my balance" | Run xclaw02 wallet balance |
| "Set up x402" / "Set up payments" | Run xclaw02 openclaw init |
| "What networks do you support?" | List supported networks (Base is primary; also Ethereum, Arbitrum, Optimism, Polygon) |
| "How much does X cost?" | Probe the URL with xclaw02 probe to get pricing |
| "Create a wallet" | Run xclaw02 wallet create - remind user to save the private key securely |
| "I want to charge for my API" | Show the Express.js or FastAPI middleware examples |
npx xclaw02 openclaw init
pip install xclaw02
xclaw02 openclaw init
This will:
~/.openclaw/skills/xclaw02/PAYMENT-SIGNATURE headerThe payment is gasless for the payer - the facilitator handles gas fees.
| Command | Description |
|---------|-------------|
| xclaw02 openclaw init | Set up xClaw02 for this agent |
| xclaw02 openclaw status | Check setup status and balance |
| xclaw02 probe | Check if URL requires payment and get price |
| xclaw02 pay | Pay for a resource (requires XCLAW02_PRIVATE_KEY) |
| xclaw02 pay | Preview payment without paying |
| xclaw02 pay | Pay with spending limit |
| xclaw02 wallet create | Create a new wallet |
| xclaw02 wallet balance | Check USDC balance on Base |
| xclaw02 wallet from-mnemonic | Restore wallet from mnemonic |
| xclaw02 networks | List supported networks |
$ xclaw02 probe https://api.example.com/paid
{
"status": "payment_required",
"price": "0.05",
"currency": "USDC",
"network": "base",
"recipient": "0x1234...abcd",
"description": "Premium API access"
}
$ xclaw02 wallet balance 0xYourAddress
{
"address": "0xYourAddress",
"network": "base",
"balance": "12.50",
"token": "USDC"
}
$ xclaw02 pay https://api.example.com/paid --max-amount 0.10
{
"status": "success",
"paid": "0.05",
"txHash": "0xabc123...",
"response": { ... }
}
const { createSigner, x402Fetch } = require('xclaw02');
// Private key format: 0x followed by 64 hex characters
const signer = await createSigner('eip155:8453', process.env.XCLAW02_PRIVATE_KEY);
const response = await x402Fetch('https://api.example.com/paid', signer, {
maxAmount: '0.10' // Maximum USDC to spend
});
const data = await response.json();
from xclaw02 import create_signer, x402_requests
import os
# Private key format: 0x followed by 64 hex characters
signer = create_signer('eip155:8453', os.environ['XCLAW02_PRIVATE_KEY'])
with x402_requests(signer, max_amount='0.10') as session:
response = session.get('https://api.example.com/paid')
data = response.json()
Want other agents to pay you? Add a paywall to your API:
const express = require('express');
const { x402Express } = require('xclaw02');
const app = express();
app.use(x402Express('0xYourAddress', {
'/api/premium': {
amount: '0.05', // $0.05 USDC per request
asset: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
network: 'eip155:8453'
}
}));
app.get('/api/premium', (req, res) => {
res.json({ data: 'Premium content here' });
});
from fastapi import FastAPI
from xclaw02 import x402_fastapi
app = FastAPI()
app.add_middleware(x402_fastapi(
'0xYourAddress',
{
'/api/premium': {
'amount': '0.05',
'asset': '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
'network': 'eip155:8453'
}
}
))
@app.get("/api/premium")
async def premium_endpoint():
return {"data": "Premium content here"}
| Network | CAIP-2 ID | Token | Notes |
|---------|-----------|-------|-------|
| Base | eip155:8453 | USDC | Primary - fast, cheap, recommended |
| Base Sepolia | eip155:84532 | USDC | Testnet |
| Ethereum | eip155:1 | USDC | Higher fees |
| Arbitrum | eip155:42161 | USDC | |
| Optimism | eip155:10 | USDC | |
| Polygon | eip155:137 | USDC | |
Base is the default network. To use others, set XCLAW02_NETWORK environment variable.
Facilitators handle payment verification and on-chain settlement. The x402 ecosystem has many independent facilitators:
| Name | URL | Notes |
|------|-----|-------|
| Primer | https://x402.primer.systems | Default |
| Coinbase | https://api.cdp.coinbase.com/platform/v2/x402 | |
| x402.org | https://x402.org/facilitator | Testnet only |
| PayAI | https://facilitator.payai.network | |
| Corbits | https://facilitator.corbits.dev | |
| Dexter | https://x402.dexter.cash | |
| Heurist | https://facilitator.heurist.xyz | |
| Kobaru | https://gateway.kobaru.io | |
| Nevermined | https://api.live.nevermined.app/api/v1/ | |
| Openfacilitator | https://pay.openfacilitator.io | |
| Solpay | https://x402.solpay.cash | |
| xEcho | https://facilitator.xechoai.xyz | |
To use a different facilitator, set XCLAW02_FACILITATOR environment variable.
| Variable | Format | Description |
|----------|--------|-------------|
| XCLAW02_PRIVATE_KEY | 0x + 64 hex chars | Wallet private key (required for payments) |
| XCLAW02_NETWORK | eip155:8453, base, etc. | Default network (default: base) |
| XCLAW02_MAX_AMOUNT | 0.10 | Default max payment amount in USDC |
| XCLAW02_FACILITATOR | URL | Facilitator URL override |
| Error Code | Meaning | What to Do |
|------------|---------|------------|
| INSUFFICIENT_FUNDS | Wallet balance too low | Tell user to fund wallet with USDC on Base |
| AMOUNT_EXCEEDS_MAX | Payment exceeds maxAmount | Ask user to approve higher amount, then retry with --max-amount |
| SETTLEMENT_FAILED | On-chain settlement failed | Wait a moment and retry, or try a different facilitator |
| INVALID_RESPONSE | Malformed 402 response | The URL may not support x402 properly |
| NETWORK_MISMATCH | Wrong network | Check the 402 response for required network, set XCLAW02_NETWORK |
0x followed by 64 hexadecimal charactersx402 is an open standard with multiple implementations:
Official Coinbase SDK - The reference implementation with Go support and Solana (SVM) in addition to EVM chains:
x402 skill by @notorious-d-e-vWhen to use alternatives:
All x402 implementations are interoperable - a client using any SDK can pay a server using any other SDK, as long as they share a supported network and facilitator.
Generated Feb 24, 2026
An AI agent needs to retrieve data from a paid API that returns a 402 Payment Required response. The agent uses xClaw02 to probe the URL, confirm the price with the user, and automatically pay with USDC on Base, enabling seamless access to premium data sources like financial APIs or specialized datasets.
A freelancer offers custom API endpoints for tasks like image processing or data analysis. They integrate xClaw02 middleware into their Express.js or FastAPI server to charge per request, allowing clients to pay automatically via 402 responses, streamlining microtransactions for on-demand services.
A company manages internal APIs that require payment for usage across departments. Using xClaw02, they set up wallets and configure payments to track expenses, ensuring secure, gasless transactions on EVM chains like Base for accessing proprietary tools or cloud resources.
A developer building a web application needs to test 402 payment integrations without real funds. They use xClaw02 with Base Sepolia testnet to simulate payments, probe URLs, and validate payment signatures, ensuring robust error handling and user experience before production deployment.
A content creator offers exclusive API access to their media library, such as video clips or articles. By implementing xClaw02 paywalls, they charge small USDC fees per request, enabling fans to pay directly through AI agents or apps, reducing reliance on traditional payment gateways.
Developers or businesses charge small fees per API call using x402 protocol. By integrating xClaw02 middleware, they set dynamic pricing, receive USDC payments instantly on Base, and reduce overhead from subscription models, appealing to users needing occasional access without long-term commitments.
A platform hosts AI agents that offer paid services like data analysis or automation. Agents use xClaw02 to handle payments when users request premium tasks, with revenue shared between the platform and service providers, leveraging gasless transactions to keep costs low and scalability high.
Companies adopt xClaw02 to streamline internal payment workflows for resource access across teams. They act as facilitators, managing wallets and balances to track departmental spending on APIs, with potential to extend to B2B partnerships by offering paid integrations to external clients.
💬 Integration Tip
Start by setting up xClaw02 with 'openclaw init', fund your wallet with USDC on Base, and test payments using the probe command to avoid surprises with API costs.
Connect Claude to Clawdbot instantly and keep it connected 24/7. Run after setup to link your subscription, then auto-refreshes tokens forever.
ERC-8004 Trustless Agents - Register, discover, and build reputation for AI agents on Ethereum. Use when registering agents on-chain, querying agent registries, giving/receiving reputation feedback, or interacting with the AI agent trust layer.
Autonomous crypto trading on Base via Bankr. Use for trading tokens, monitoring launches, executing strategies, or managing a trading portfolio. Triggers on "trade", "buy", "sell", "launch", "snipe", "profit", "PnL", "portfolio balance", or any crypto trading task on Base.
Deploy ERC20 tokens on Base using Clanker SDK. Create tokens with built-in Uniswap V4 liquidity pools. Supports Base mainnet and Sepolia testnet. Requires PRIVATE_KEY in config.
Query DeFi portfolio data across 50+ chains via Zapper's GraphQL API. Use when the user wants to check wallet balances, DeFi positions, NFT holdings, token prices, or transaction history. Supports Base, Ethereum, Polygon, Arbitrum, Optimism, and more. Requires ZAPPER_API_KEY.
Interact with Solana blockchain via Helius APIs. Create/manage wallets, check balances (SOL + tokens), send transactions, swap tokens via Jupiter, and monitor addresses. Use for any Solana blockchain operation, crypto wallet management, token transfers, DeFi swaps, or portfolio tracking.