x402-agent-payments-guide
БесплатноБез исполняемых скриптовНе проверенGuide to the x402 protocol — HTTP-native micropayments for AI agents. Enables agents to pay for API calls, data, and services using stablecoins (USDC, USDs)…
от nirholas★ 289 звёзд на GitHubОб этом скилле
x402 Agent Payments Guide
x402 is the HTTP-native micropayment protocol for AI agents. It enables agents to pay for API calls, data, and services using stablecoins — no API keys, no subscriptions, just a signed payment header.
How x402 Works
Agent → HTTP Request + x402 Payment Header → Server
│
Verify Payment
│
✅ Valid → Serve Content
❌ Invalid → 402 Payment Required
The Flow
- Agent makes HTTP request to a paid endpoint
- Server returns
402 Payment Requiredwith pricing info - Agent signs an EIP-712 payment authorization
- Agent retries with
X-402-Paymentheader - Server verifies signature and serves content
- Payment settles on-chain (batched for efficiency)
Payment Header
X-402-Payment: {
"version": "1",
"sender": "0xAgentAddress",
"amount": "0.001",
"token": "USDs",
"chain": "arbitrum",
"signature": "0x...",
"nonce": 42,
"expiry": 1735689600
}
Supported Tokens
| Token | Chains | Best For |
|---|---|---|
| USDs | Arbitrum | Sperax ecosystem payments |
| USDC | Ethereum, Arbitrum, Base | Standard payments |
| USDT | Ethereum, Arbitrum | Alternative stablecoin |
For Agents (Paying)
Setup
import { X402Client } from '@x402/client';
const client = new X402Client({
privateKey: process.env.AGENT_PRIVATE_KEY,
defaultToken: 'USDs',
defaultChain: 'arbitrum',
maxPaymentPerRequest: '0.01', // Safety limit
maxPaymentPerHour: '1.00' // Hourly limit
});
Making Paid Requests
// Automatic payment handling
const response = await client.fetch('https://api.example.com/data', {
method: 'GET'
});
// If 402 → signs payment → retries → returns data
Budget Controls
const client = new X402Client({
budget: {
perRequest: '0.01', // Max per single request
perHour: '1.00', // Max per hour
perDay: '10.00', // Max per day
perMonth: '100.00', // Max per month
whitelist: ['api.chat.sperax.io', 'api.coingecko.com'] // Trusted domains
}
});
For Servers (Receiving)
Express Middleware
import { x402Middleware } from '@x402/server';
app.use('/api/premium/*', x402Middleware({
price: '0.001', // Price per request in USDs
token: 'USDs',
chain: 'arbitrum',
recipient: '0xYourAddress'
}));
app.get('/api/premium/data', (req, res) => {
res.json({ data: 'premium content' });
});
Dynamic Pricing
app.use('/api/data/*', x402Middleware({
pricing: (req) => {
if (req.path.includes('historical')) return '0.005';
if (req.path.includes('realtime')) return '0.01';
return '0.001';
},
token: 'USDs',
chain: 'arbitrum'
}));
MCP Integration
x402 is native in the MCP ecosystem:
{
"mcpServers": {
"premium-data": {
"command": "npx",
"args": ["@premium/mcp-server"],
"x402": {
"wallet": "0xAgentWallet",
"maxBudget": "1.00",
"token": "USDs"
}
}
}
}
Use Cases
| Use Case | Example | Typical Price |
|---|---|---|
| API Calls | Market data, analytics | $0.001/req |
| AI Inference | LLM completions | $0.01-0.10/req |
| Data Access | On-chain data, research | $0.005/req |
| Content | Paywalled articles, reports | $0.01-0.50 |
| Tool Usage | MCP tool invocations | $0.001-0.01 |
Sperax + x402
USDs is ideal for x402 payments:
- Auto-yield: Agent wallets holding USDs earn yield while waiting
- Low gas: Arbitrum L2 means sub-cent transaction costs
- Stable: Always $1, no price volatility risk
Links
- Spec: https://www.x402.org
- GitHub: https://github.com/nirholas/x402
- npm: https://www.npmjs.com/package/@x402/client
- EIP-712: https://eips.ethereum.org/EIPS/eip-712
- Sperax USDs: https://app.sperax.io
Установить x402-agent-payments-guide в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл x402-agent-payments-guide?
Guide to the x402 protocol — HTTP-native micropayments for AI agents. Enables agents to pay for API calls, data, and services using stablecoins (USDC, USDs) without API keys or subscriptions. Built on EIP-712 signed payment headers.
Как установить скилл x402-agent-payments-guide?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл x402-agent-payments-guide запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic