Revolutionary AI Agent Payment Infrastructure β HTTP 402 payments with yield-bearing USDs stablecoin on Arbitrum
X402 is a complete payment protocol implementation for AI agents, combining:
- HTTP 402 - Payment Required standard for programmatic payments
- Sperax USDs - Auto-yield stablecoin (8-25% APY) on Arbitrum
- EIP-3009 - Gasless transfer authorization
- Arbitrum L2 - Low-cost, fast transactions
| Feature | Traditional Payments | X402 + USDs |
|---|---|---|
| Fees | 2-3% + fixed | ~$0.001 gas |
| Settlement | Days | Seconds |
| Yield | 0% | 8-25% APY |
| AI Native | β | β |
| Gasless | β | β (EIP-3009) |
| Micropayments | β | β |
| Package | Description |
|---|---|
@x402/sdk |
Core SDK for X402 payments |
@x402/cli |
Command-line interface |
@x402/sperax-mcp |
MCP tools for AI agents |
facilitator |
Payment verification server |
yield-tracker |
USDs yield monitoring |
contracts |
Solidity smart contracts |
# Clone the repo
git clone https://github.com/nirholas/x402.git
cd x402
# Install dependencies
pnpm install
# Copy environment config
cp .env.example .env
# Start the facilitator server
pnpm facilitator:dev
# In another terminal, start yield tracker
pnpm yield-trackerimport { X402Client } from '@x402/sdk';
const client = new X402Client({
network: 'arbitrum',
facilitatorUrl: 'http://localhost:3002'
});
// Gasless payment with EIP-3009
const { txHash } = await client.pay({
recipient: '0x...',
amount: '1.50', // $1.50 USDs
token: 'USDs',
gasless: true
});
console.log('Payment confirmed:', txHash);{
"tool": "x402_pay_with_usds",
"arguments": {
"recipient": "0x...",
"amount": "1.50",
"gasless": true,
"memo": "API call payment"
}
}USDs automatically earns yield while sitting in your wallet:
import { SperaxClient } from '@x402/sdk';
const client = new SperaxClient({ network: 'arbitrum' });
// Check balance with yield earned
const { balance, yieldEarned, apy } = await client.getBalanceWithYield(address);
console.log(`Balance: $${balance}`);
console.log(`Yield Earned: $${yieldEarned}`);
console.log(`Current APY: ${apy}%`);βββββββββββββββ HTTP 402 βββββββββββββββββββ
β AI Agent β βββββββββββββββββββ API Server β
β (Payer) β β (Paywall) β
ββββββββ¬βββββββ ββββββββββ¬βββββββββ
β β
β EIP-3009 Auth β Verify
βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Facilitator Server β
β β’ Verify payment authorizations β
β β’ Submit transactions β
β β’ Track yields β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ
β Arbitrum Network β
β βββββββββββββββββββββ β
β β USDs Token β β
β β (Auto-Yield) β β
β βββββββββββββββββββββ β
βββββββββββββββββββββββββββ
Pay per API call with micropayments. No subscriptions, no minimums.
Paywall articles, videos, or data with instant USDs payments.
Automatic 80/20 split between developers and platforms.
Pay-as-you-go subscriptions that auto-renew with yield earnings.
| Contract | Address |
|---|---|
| USDs Token | 0xD74f5255D557944cf7Dd0E45FF521520002D5748 |
| Sperax Vault | 0x8EC1877698ACF262Fe8Ad8a295ad94D6ea258988 |
| Revenue Splitter | Deploy your own |
| Contract | Address |
|---|---|
| USDs Token | See deployment docs |
# Run all tests
pnpm test
# Run contract tests
pnpm contracts:test
# Build all packages
pnpm build
# Format code
pnpm format
# Lint
pnpm lintContributions are welcome! Please read our Contributing Guide first.
MIT License - see LICENSE for details.
Built with β€οΈ for the AI economy
X402 is not affiliated with Sperax or Coinbase. USDs is a product of Sperax Foundation.