x402-payments

Agent-to-agent payments via HTTP 402 + on-chain escrow. Let agents pay each other for API calls, services, and data.

16 stars

Best use case

x402-payments is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Agent-to-agent payments via HTTP 402 + on-chain escrow. Let agents pay each other for API calls, services, and data.

Teams using x402-payments should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/x402-payments/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/backend/x402-payments/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/x402-payments/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How x402-payments Compares

Feature / Agentx402-paymentsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Agent-to-agent payments via HTTP 402 + on-chain escrow. Let agents pay each other for API calls, services, and data.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# X402 Agent Payments

Let your agent pay (and get paid by) other agents. HTTP 402 + on-chain escrow.

## How It Works

```
Agent A                    Agent B
   │                          │
   │ GET /api/data            │
   │ ─────────────────────►   │
   │                          │
   │ 402 Payment Required     │
   │ X-Price: 0.01 USDC       │
   │ ◄─────────────────────   │
   │                          │
   │ Lock funds in escrow     │
   │ ══════════════════════►  │ (on-chain)
   │                          │
   │ GET /api/data            │
   │ X-Payment-Proof: 0x...   │
   │ ─────────────────────►   │
   │                          │
   │ 200 OK + data            │
   │ ◄─────────────────────   │
   │                          │
   │ Release escrow           │
   │ ◄══════════════════════  │ (on-chain)
```

## Quick Start

### As a Buyer (Paying Agent)

```typescript
import { X402Client } from './x402-client';

const client = new X402Client({
  wallet: '0x...',
  privateKey: process.env.PRIVATE_KEY,
  facilitatorUrl: 'http://localhost:8403'
});

// Call a paid API - payment handled automatically
const response = await client.fetch('http://agent-b.local/api/sensor-data');
console.log(response.data);
console.log(`Paid: ${response.paymentAmount} USDC`);
```

### As a Seller (Paid Agent)

```typescript
import { X402Server } from './x402-server';
import { Hono } from 'hono';

const app = new Hono();
const x402 = new X402Server({
  wallet: '0x...',
  facilitatorUrl: 'http://localhost:8403'
});

// Protect an endpoint with payment requirement
app.get('/api/sensor-data', x402.protect({ price: 0.01 }), (c) => {
  return c.json({ temperature: 23.5, humidity: 45 });
});

// Free endpoint
app.get('/api/status', (c) => {
  return c.json({ online: true });
});
```

## Run the Facilitator

The facilitator coordinates payments and monitors escrow:

```bash
cd apps/x402-facilitator
bun run start
```

```
🔷 X402 Facilitator Started
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 HTTP:      http://0.0.0.0:8403
🔌 WebSocket: ws://0.0.0.0:8403
⛓️  Escrow:    0x5FbDB2315678afecb367f032d93F642f64180aa3
🌐 Provider:  http://localhost:8545
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

## Local Development

```bash
# Start local blockchain
anvil

# Deploy escrow contract
cd contracts && forge script script/Deploy.s.sol --broadcast

# Start facilitator
cd apps/x402-facilitator && bun run start

# Run example agents
bun run dev:alice   # Seller on :3001
bun run dev:bob     # Buyer on :3002
```

## Payment Flow

1. **Request** — Buyer calls seller API
2. **Challenge** — Seller returns 402 with price
3. **Lock** — Buyer locks funds in escrow contract
4. **Proof** — Buyer retries with payment proof header
5. **Deliver** — Seller returns data
6. **Release** — Escrow releases funds to seller

If seller doesn't deliver, buyer can dispute and get refund.

## Headers

| Header | Direction | Description |
|--------|-----------|-------------|
| `X-Price` | Response | Required payment amount |
| `X-Payment-Address` | Response | Seller's wallet |
| `X-Payment-Proof` | Request | Transaction hash proving payment |
| `X-Escrow-Id` | Both | Escrow transaction ID |

## Chains Supported

- Local (Anvil)
- Base
- Arbitrum
- Any EVM chain

## Why Escrow?

- **Trustless** — No reputation needed
- **Atomic** — Payment and delivery linked
- **Reversible** — Dispute mechanism for non-delivery
- **Cheap** — L2s make this practical

## Links

- [HTTP 402 Spec](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402)
- [QUSD Qualia](https://github.com/QUSD-ai/qualia)
- [A2A Protocol](https://a2a-protocol.org)

Related Skills

x402-client

16
from diegosouzapw/awesome-omni-skill

Client for interacting with the x402 payment service when receiving HTTP 402 responses.

Bankr x402 SDK - Job Management

16
from diegosouzapw/awesome-omni-skill

This skill should be used when the user asks about "job status", "check if request completed", "cancel request", "why is my request taking so long", "poll for result", "batch requests", "retry failed request", "request timeout", "async operations", "job lifecycle", "manual polling", or needs advanced control over SDK async operations, manual job polling, batch processing, retry logic, or job cancellation.

bgo

16
from diegosouzapw/awesome-omni-skill

Automated Blender build-go workflow. Automatically builds, removes old version, installs, enables, and launches Blender with your extension/add-on. Use when you want to quickly test changes, execute complete build-to-launch cycle, or run custom packaging scripts with automatic Blender launch.

Coding & Development

maintenance

16
from diegosouzapw/awesome-omni-skill

Cleans up and organizes project files. Use when user mentions '整理', 'cleanup', 'アーカイブ', 'archive', '肥大化', 'Plans.md', 'session-log', or asks to clean up old tasks, archive completed items, or organize files. Do NOT load for: 実装作業, レビュー, 新機能開発, デプロイ.

hello-skill

16
from diegosouzapw/awesome-omni-skill

每次对话开始时,声明"[Skills✏️已加载]"

zylvie-automation

16
from diegosouzapw/awesome-omni-skill

Automate Zylvie tasks via Rube MCP (Composio). Always search tools first for current schemas.

zoominfo-automation

16
from diegosouzapw/awesome-omni-skill

Automate Zoominfo tasks via Rube MCP (Composio). Always search tools first for current schemas.

zoho-invoice-automation

16
from diegosouzapw/awesome-omni-skill

Automate Zoho Invoice tasks via Rube MCP (Composio): invoices, estimates, expenses, clients, and payment tracking. Always search tools first for current schemas.

zoho-inventory-automation

16
from diegosouzapw/awesome-omni-skill

Automate Zoho Inventory tasks via Rube MCP (Composio): items, orders, warehouses, shipments, and stock management. Always search tools first for current schemas.

zoho-bigin-automation

16
from diegosouzapw/awesome-omni-skill

Automate Zoho Bigin tasks via Rube MCP (Composio): pipelines, contacts, companies, products, and small business CRM. Always search tools first for current schemas.

zoho_desk-automation

16
from diegosouzapw/awesome-omni-skill

Zoho Desk automation via Rube MCP -- toolkit not currently available in Composio; no ZOHO_DESK_ tools found

zoho-automation

16
from diegosouzapw/awesome-omni-skill

Automate Zoho tasks via Rube MCP (Composio). Always search tools first for current schemas.