Agentic skill for AI agents to seamlessly pay for x402-gated services.
x402-skill is an early-stage Rust project in the AI payments / x402 ecosystem, focused on x402, Agent. It currently has 5 GitHub stars and 1 forks, and sits alongside related tools like machi, ProwlFi, x402-openai-python, AIephant-AI-Agent-Gateway, AgenticDeFi-Trainer, AgenticDeFi-Trainer.
This project provides the tooling and agentic skill for AI agents to seamlessly pay for x402-gated services. If you are looking for the agentic skill to request and receive payments, checkout https://money.flows.network
Copy and paste the following sentence to give your agent the ability to make payments, and purchase products or services on its own.
For OpenClaw:
Read https://raw.githubusercontent.com/second-state/x402-skill/refs/heads/master/openclaw/skills/x402/install.md and follow the instructions to set up the skill to make payments to x402-gated web or agent services.
For Claude Code:
Read https://raw.githubusercontent.com/second-state/x402-skill/refs/heads/master/claude/skills/x402/install.md and follow the instructions to set up the skill to make payments to x402-gated web or agent services.
| Component | Language | Description |
|---|---|---|
| x402curl | Rust | Drop-in curl replacement with automatic x402 payment handling |
| Echo Server | Python | Demo FastAPI server with an x402 payment-gated endpoint |
| x402-retry | Skill | AI agent skill that detects HTTP 402 responses and retries with x402curl |
┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐
│ AI agent │ │ x402curl │ │ Paid API │
│ (runs skill) │ │ │ │ (x402 gated) │
└────────┬────────┘ └──────┬───────┘ └────────┬────────┘
│ │ │
│ Execute skill │ │
│ (uses x402curl) │ │
│────────────────────>│ │
│ │ HTTP Request │
│ │─────────────────────>│
│ │ 402 + Payment Info │
│ │<─────────────────────│
│ │ [Auto-pay with │
│ │ private key] │
│ │ Request + Payment │
│ │─────────────────────>│
│ │ 200 + Response │
│ │<─────────────────────│
│ Response │ │
│<────────────────────│ │
cargo install --path .
x402curl supports two wallet formats: raw private key or Keystore v3 (JSON wallet file). If both are configured, the private key takes priority.
Option A: Private key
echo 'X402_PRIVATE_KEY=your_64_hex_char_key' >> .env
Option B: Keystore v3 wallet
echo 'X402_WALLET=/path/to/wallet.json' >> .env
echo 'X402_WALLET_PASSWORD=your_password' >> .env
Credentials are resolved in this order:
--x402-key CLI flagX402_PRIVATE_KEY environment variable / .env file--x402-wallet + --x402-wallet-password CLI flagsX402_WALLET + X402_WALLET_PASSWORD environment variables / .env file~/.x402/config global TOML config filex402curl is a drop-in replacement for curl that automatically detects 402 responses, signs a payment, and retries the request.
# Basic request - payment handled automatically
x402curl -X POST https://api.example.com/endpoint \
-H "Content-Type: application/json" \
-d '{"key": "value"}'
# Check wallet USDC balance (default: Base mainnet)
x402curl --x402-balance
# Check balance on Base Sepolia testnet
x402curl --x402-balance --x402-rpc-url https://sepolia.base.org
# Check any ERC-20 token balance (decimals auto-detected)
x402curl --x402-balance \
--x402-rpc-url https://eth.llamarpc.com \
--x402-token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
# Preview payment requirements without paying
x402curl --x402-dry-run -X POST https://api.example.com/endpoint
# Prompt for confirmation before paying
x402curl --confirm -X POST https://api.example.com/endpoint
# File upload via multipart form
x402curl -X POST https://api.example.com/upload -F "file=@document.pdf"
# Use a Keystore v3 wallet file instead of a raw private key
x402curl --x402-wallet wallet.json --x402-wallet-password mypassword \
-X POST https://api.example.com/endpoint
# Verbose mode - shows signing address, payment flow, headers
x402curl -v -X POST https://api.example.com/endpoint
| Flag | Description |
|---|---|
-X |
HTTP method |
-H |
Request header (repeatable) |
-d |
Request body (@filename to read from file) |
--data-binary |
Raw binary data |
-F |
Multipart form field (repeatable) |
-o |
Write output to file |
-u |
Basic auth (user:password) |
-L |
Follow redirects |
-f |
Fail silently on HTTP errors |
-s |
Silent mode |
-v |
Verbose mode |
| Flag | Description |
|---|---|
--x402-key |
Override private key for this request |
--x402-wallet |
Path to Keystore v3 wallet (JSON) file |
--x402-wallet-password |
Password for the keystore wallet file |
--x402-dry-run |
Show payment requirements without paying |
--x402-balance |
Query wallet USDC balance |
--x402-rpc-url |
Override RPC endpoint URL (default: Base mainnet) |
--x402-token |
Override ERC-20 token contract address (decimals and symbol auto-detected) |
--confirm |
Prompt before making payment |
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error (invalid args, config) |
| 2 | Network error (connection failed) |
| 3 | Payment error (insufficient funds) |
| 4 | HTTP error (4xx/5xx with -f) |
| 5 | Configuration error (no key found) |
| 6 | RPC error (balance query failed) |
A minimal FastAPI server for testing x402curl. The /echo endpoint requires $0.01 USDC on Base Sepolia.
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
cp .env.example .env
# Edit .env with your Base Sepolia wallet address
uvicorn echo_server.server:app --reload --port 8000
| Endpoint | Method | Auth | Description |
|---|---|---|---|
/health |
GET | None | Health check |
/echo |
POST | x402 ($0.01 USDC) | Echoes JSON body after payment verification and settlement |
# Returns 402 - no payment
curl -X POST http://localhost:8000/echo \
-H "Content-Type: application/json" \
-d '{"hello": "world"}'
# Pays and returns echoed body
x402curl -X POST http://localhost:8000/echo \
-H "Content-Type: application/json" \
-d '{"hello": "world"}'
A reactive Claude Code skill that automatically detects x402-compatible 402 responses and retries with x402curl. It triggers when a response has:
402 and either:X-Payment header present, or"x402Version"The skill checks that x402curl is installed and X402_PRIVATE_KEY is configured, then transparently retries the failed request. See claude/skills/x402/SKILL.md (for Claude Code) or openclaw/skills/x402/SKILL.md (for OpenClaw) for full details.
# Rust tests
cargo test
# Python tests
source .venv/bin/activate
pip install -e ".[dev]"
pytest
MIT
Agent behavior that compiles
The world's first privacy layer for AI agents on Solana — stealth addresses + x402 payments. Every payment lands at a fresh, unlinkable address.
Drop-in OpenAI Python client with transparent x402 payment support.
Alephant is an open-source AI Agent Gateway for routing, tracking, and controlling LLM usage across AI agents, members, and workflows, and for publishing agent capabilities as paid endpoints with x402 and MPP payment rails.
Autonomous AI Agent Swarm framework with x402 self-executing wallets. Empowers LLM-driven agents to trade, bridge, and manage crypto treasuries without human intervention. The ultimate Agentic DeFi toolkit for 2026.
Autonomous AI Agent Swarm framework with x402 self-executing wallets. Empowers LLM-driven agents to trade, bridge, and manage crypto treasuries without human intervention. The ultimate Agentic DeFi toolkit for 2026.
An open SDK for agentic payments. Let AI agents make payments, hold funds, and move money across chains with policy enforcement and human approval built in.
x402 payments in Rust: verify, settle, and monitor payments over HTTP 402 flows
The self-improving LLM router that optimize your agentic workflows with every runs, works with any harnesses, any models, any loops.
Production-ready x402 facilitator server.
Rust SDK for the x402 payment protocol.
An operating system built for AI agents — talk to your NixOS server instead of SSH-ing in. Typed, audited tool access with atomic rollback on every change. Research-grade; run it on a disposable box, not production.