Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions skills/payai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# PayAI Agent Skill

Discover, pay for, and sell agent services over the [x402 protocol](https://x402.gitbook.io/x402) using the [PayAI Network](https://payai.network) — USDC settlement on **Solana** and **EVM** chains, no signup.

## What is this?

This is an [Agent Skill](https://agentskills.io) for **PayAI**, the payment network for autonomous agents. It teaches an agent to:

- **Browse the Bazaar** — a live directory of paid x402 APIs and agent services (`/discovery/resources`).
- **Use the facilitator** — verify and settle payments across Solana + 9 EVM chains, no API key.
- **Sell services** — turn any HTTP endpoint into a paid, discoverable x402 resource.

For the mechanics of building and signing a payment, pair this with the companion [`x402`](../x402/) skill.

## Install

### Claude Code

```bash
mkdir -p ~/.claude/skills/payai
cp -r SKILL.md scripts ~/.claude/skills/payai/
```

### OpenAI Codex

```bash
mkdir -p ~/.codex/skills/payai
cp -r SKILL.md scripts ~/.codex/skills/payai/
```

### VS Code / GitHub Copilot

```bash
mkdir -p .github/skills/payai
cp -r SKILL.md scripts .github/skills/payai/
```

Works with any agent that supports the [Agent Skills](https://agentskills.io) standard.

## Try it (safe, no spend)

`scripts/discover.mjs` lists live paid services from the PayAI Bazaar (zero dependencies, Node 18+):

```bash
node scripts/discover.mjs # recent resources
node scripts/discover.mjs --network solana # only Solana-payable
node scripts/discover.mjs --query weather # filter by keyword
```

## Key details

| Feature | Detail |
|---|---|
| Facilitator | `https://facilitator.payai.network` (no signup) |
| Bazaar | `GET /discovery/resources` |
| Chains | Solana + 9 EVM (Base, Polygon, Arbitrum, Avalanche, Sei, X Layer, SKALE) |
| Asset | USDC (6 decimals) |
| Solana gas | Paid by the facilitator |
| Sell | `x402-express` / `x402-hono` / `x402-next` middleware |

## Links

- **Website:** https://payai.network
- **Docs:** https://docs.payai.network
- **Bazaar (live):** https://facilitator.payai.network/discovery/resources
- **Supported networks (live):** https://facilitator.payai.network/supported
- **Companion skill:** [`x402`](../x402/) — pay for any 402-gated resource
- **Example consumer:** [`sp3nd`](../sp3nd/) — buy from Amazon with USDC via PayAI

## License

MIT
182 changes: 182 additions & 0 deletions skills/payai/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
---
name: payai
description: Discover, pay for, and sell agent services over the x402 protocol using the PayAI Network. Browse the PayAI Bazaar — a live directory of paid APIs and agent services — pay any of them autonomously with USDC on Solana or EVM chains via the open PayAI facilitator, and expose your own endpoints as x402-monetized resources so other agents pay you. Use when an agent needs to find a paid tool/API/service, settle an x402 payment across chains, or accept crypto payments for the work it does.
metadata: {"openclaw":{"emoji":"🌐","homepage":"https://payai.network","primaryEnv":"SOLANA_PRIVATE_KEY"}}
---

# PayAI — The Payment Network for Autonomous Agents

## What is PayAI?

**PayAI** is an open payment network that lets AI agents **find, pay for, and sell** services to each other using the [x402 protocol](https://x402.gitbook.io/x402) — HTTP-native payments settled in stablecoins (USDC). It has three parts an agent cares about:

1. **The facilitator** (`https://facilitator.payai.network`) — a neutral, no-signup service that **verifies** and **settles** x402 payments across many chains. It settles **Solana** (and pays the gas for you) and **9 EVM chains**.
2. **The Bazaar** (`/discovery/resources`) — a live, queryable directory of paid x402 resources: APIs, tools, and agent services you can call and pay for right now.
3. **Merchant support** — libraries and facilitator endpoints that let *your* agent price an endpoint in USDC and get paid by other agents.

Think of PayAI as the marketplace + settlement layer. This skill covers **discovering** services and **selling** yours. For the mechanics of *constructing and signing a payment*, use the companion [`x402`](../x402/) skill.

## When to use this skill

- You need a capability (data, inference, a tool, a physical good) and want to **find an agent/API that sells it**.
- You have an x402 payment to **verify or settle** and need a facilitator.
- You want to know **which chains/assets** are supported before paying.
- You want to **monetize** your own agent or API so other agents pay you in USDC.

## Part 1 — Discover services (the Bazaar)

Query the live directory of paid resources:

```bash
curl -s "https://facilitator.payai.network/discovery/resources?limit=25" | jq
```

The response is a paginated list of resources:

```json
{
"x402Version": 1,
"items": [
{
"resource": "https://tripadvisor.x402.paysponge.com/api/v1/location/:locationId/details",
"type": "http",
"method": "GET",
"x402Version": 2,
"accepts": [
{
"scheme": "exact",
"network": "eip155:8453",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"payTo": "0x6302D9e6DBB22fEC3c350551568Bb39B4b35Ad57",
"amount": "10000",
"maxTimeoutSeconds": 300
}
],
"inputSchema": { "type": "http", "method": "GET", "pathParams": { "locationId": "154943" } },
"outputSchema": { "type": "json", "example": {} },
"lastUpdated": "2026-07-24T05:18:11.665Z"
}
],
"pagination": { "limit": 25, "offset": 0 }
}
```

Each item tells you everything needed to call and pay for it:

- **`resource`** — the URL to call (with `:param` path params described in `inputSchema`).
- **`method`** — HTTP verb.
- **`x402Version`** — the item's protocol version. **v2** items use CAIP-2 networks (`eip155:8453`, `solana:<genesis>`) and the `PAYMENT-SIGNATURE` header; **v1** items use plain names (`base`) and `X-PAYMENT`. (The discovery envelope's own `x402Version` is separate — read each item's.)
- **`accepts`** — the same payment-requirements array you'd get from a `402` (network, asset, price, `payTo`).
- **`inputSchema` / `outputSchema`** — how to call it and what comes back.

### Workflow: find → pay → use

1. **Search** the Bazaar for a resource that does what you need (filter `items` by keywords in `resource`, or by a `network`/asset you hold).
2. **Read the price** from `accepts[].amount` (base units; USDC = 6 decimals).
3. **Call + pay** using the [`x402`](../x402/) skill — send the request, get a `402`, build the payment, retry with the payment header (`X-PAYMENT` for v1, `PAYMENT-SIGNATURE` for v2 — matched to the item's `x402Version`).

`scripts/discover.mjs` (zero dependencies, Node 18+) fetches the Bazaar and prints a readable table, with optional filtering:

```bash
node scripts/discover.mjs # list recent resources
node scripts/discover.mjs --network solana # only Solana-payable resources
node scripts/discover.mjs --query weather # match resource URL/description
```

## Part 2 — The facilitator API

Base URL: `https://facilitator.payai.network`. No API key, no signup.

### `GET /supported` — which chains & schemes settle

```bash
curl -s https://facilitator.payai.network/supported | jq '.kinds[] | {scheme, network}'
```

Returns the authoritative list. Currently:

| Chain | Networks | x402 versions |
|---|---|---|
| **Solana** | `solana`, `solana-devnet`, `solana:<genesis>` (v2) | v1 + v2 |
| **Base** | `base`, `base-sepolia`, `eip155:8453` | v1 + v2 (incl. `upto`) |
| **Polygon** | `polygon`, `polygon-amoy`, `eip155:137` | v1 + v2 |
| **Arbitrum** | `arbitrum`, `arbitrum-sepolia`, `eip155:42161` | v1 + v2 |
| **Avalanche** | `avalanche`, `avalanche-fuji`, `eip155:43114` | v1 + v2 |
| **Sei** | `sei`, `sei-testnet`, `eip155:1329` | v1 + v2 |
| **X Layer** | `xlayer`, `xlayer-testnet`, `eip155:196` | v1 + v2 |
| **SKALE** | `skale-base`, `skale-base-sepolia` | v1 + v2 |

On Solana, the facilitator is the **fee payer** — the payer spends only USDC, no SOL. Always trust the live `/supported` output over this table.

### `POST /verify` — check a payment is valid (no settlement)

```json
POST /verify
{ "paymentPayload": { … }, "paymentRequirements": { … } }
→ { "isValid": true, "payer": "…" }
```

### `POST /settle` — broadcast/settle the payment on-chain

```json
POST /settle
{ "paymentPayload": { … }, "paymentRequirements": { … } }
→ { "success": true, "transaction": "<signature-or-hash>", "network": "solana", "payer": "…" }
```

Servers usually call `/verify` + `/settle` for you when you send the payment header (`X-PAYMENT` in v1, `PAYMENT-SIGNATURE` in v2). Some flows (e.g. the [`sp3nd`](../sp3nd/) skill in this repo) have the **client** call `/verify` then `/settle` directly. The payload shapes are defined by the [`x402`](../x402/) skill.

## Part 3 — Sell your own services (get paid by agents)

Any HTTP endpoint can become a paid, discoverable x402 resource:

1. **Gate the route** so it returns `402 Payment Required` with an `accepts` array (your `scheme`, `network`, `payTo`, and price). The x402 server middlewares make this a few lines: **v2** — `@x402/express`, `@x402/hono`, `@x402/next` (built on `@x402/core` + a scheme from `@x402/evm` / `@x402/svm`); **v1** — `x402-express`, `x402-hono`, `x402-next`.
2. **Settle** incoming payments via the PayAI facilitator — point the middleware's facilitator client at `https://facilitator.payai.network` and it calls `/verify` + `/settle` for you.
3. **Get discovered** — to appear in the Bazaar (`/discovery/resources`), a **v2** route must declare the discovery extension with `declareDiscoveryExtension()` from `@x402/extensions/bazaar` (hand-rolling `extensions.bazaar.schema` passes through but **fails silently** in the discovery crawler). See the seller guide at https://docs.payai.network.

Conceptually, a v2 Express seller settled by PayAI:

```javascript
// npm i @x402/express @x402/core @x402/evm
import express from "express";
import { paymentMiddleware } from "@x402/express";
import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server";
import { ExactEvmScheme } from "@x402/evm/exact/server";

const app = express();
const payTo = "0xYourWallet";

const facilitator = new HTTPFacilitatorClient({ url: "https://facilitator.payai.network" }); // PayAI settles
const server = new x402ResourceServer(facilitator);
server.register("eip155:*", new ExactEvmScheme()); // add ExactSvmScheme from @x402/svm for Solana

app.use(paymentMiddleware(
{
"GET /premium": {
accepts: [{ scheme: "exact", price: "$0.01", network: "eip155:8453", payTo }], // CAIP-2
description: "Premium content",
mimeType: "application/json",
},
},
server,
));
app.get("/premium", (_req, res) => res.json({ data: "🎁 paid content" }));
app.listen(3000);
```

> Confirm exact signatures against the x402 docs (https://x402.gitbook.io/x402) and PayAI's seller docs — config formats evolve. Start on a testnet (`base-sepolia`, `solana-devnet`).

## A real consumer in this repo

The [`sp3nd`](../sp3nd/) skill (buy from Amazon with USDC) settles every order through the **PayAI facilitator** on **Solana** — a working example of x402 + PayAI end to end.

## Key facts

- **Facilitator:** `https://facilitator.payai.network` — no signup, multi-chain.
- **Bazaar / discovery:** `GET /discovery/resources` (paginated `items[]`).
- **Verify / settle:** `POST /verify`, `POST /settle` with `{ paymentPayload, paymentRequirements }`.
- **Supported:** `GET /supported` — Solana (+ gas paid for you) and 9 EVM chains.
- **Asset:** USDC, 6 decimals. Solana mint `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`; Base contract `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`.
- **Pay mechanics + v1/v2 headers:** see the [`x402`](../x402/) skill (v2 uses `PAYMENT-SIGNATURE` / `PAYMENT-RESPONSE`; v1 uses `X-PAYMENT` / `X-PAYMENT-RESPONSE`).
- **Seller middlewares:** v2 — `@x402/express`, `@x402/hono`, `@x402/next` (+ `@x402/extensions/bazaar` for discovery); v1 — `x402-express`, `x402-hono`, `x402-next`.
- **Website:** https://payai.network · **Docs:** https://docs.payai.network
10 changes: 10 additions & 0 deletions skills/payai/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"owner": "PayAINetwork",
"slug": "payai",
"displayName": "PayAI — Payment Network for Agents",
"latest": {
"version": "1.0.0",
"publishedAt": 1784871635427
},
"history": []
}
73 changes: 73 additions & 0 deletions skills/payai/scripts/discover.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env node
// discover.mjs — Browse the PayAI Bazaar: live x402 paid resources you can call.
//
// Usage:
// node discover.mjs [--network <name>] [--query <text>] [--limit <n>] [--json]
//
// Examples:
// node discover.mjs # recent resources
// node discover.mjs --network solana # only resources payable on Solana
// node discover.mjs --query weather # match resource URL / description
//
// Zero dependencies — requires Node 18+ (global fetch).

const FACILITATOR = process.env.PAYAI_FACILITATOR || "https://facilitator.payai.network";

const args = process.argv.slice(2);
let network, query, limit = 25, asJson = false;
for (let i = 0; i < args.length; i++) {
if (args[i] === "--network") network = (args[++i] || "").toLowerCase();
else if (args[i] === "--query") query = (args[++i] || "").toLowerCase();
else if (args[i] === "--limit") limit = Number(args[++i]) || 25;
else if (args[i] === "--json") asJson = true;
else if (args[i] === "-h" || args[i] === "--help") {
console.log("Usage: node discover.mjs [--network <name>] [--query <text>] [--limit <n>] [--json]");
process.exit(0);
}
}

const ASSETS = {
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: { symbol: "USDC", decimals: 6 },
"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913": { symbol: "USDC", decimals: 6 },
};
const assetInfo = a => ASSETS[a] || ASSETS[String(a).toLowerCase()] || { symbol: "token", decimals: 6 };

function human(baseUnits, decimals) {
try {
const n = BigInt(baseUnits), d = BigInt(10) ** BigInt(decimals);
const frac = (n % d).toString().padStart(decimals, "0").replace(/0+$/, "");
return frac ? `${n / d}.${frac}` : `${n / d}`;
} catch { return String(baseUnits); }
}

const res = await fetch(`${FACILITATOR}/discovery/resources?limit=${Math.max(limit * 3, 50)}`);
if (!res.ok) {
console.error(`Failed to reach Bazaar: HTTP ${res.status} ${res.statusText}`);
process.exit(1);
}
const data = await res.json();
let items = data.items || [];

if (network) items = items.filter(it => (it.accepts || []).some(a => String(a.network).toLowerCase().includes(network)));
if (query) items = items.filter(it => JSON.stringify(it).toLowerCase().includes(query));
items = items.slice(0, limit);

if (asJson) { console.log(JSON.stringify(items, null, 2)); process.exit(0); }

console.log(`\nPayAI Bazaar — ${items.length} resource(s) (facilitator: ${FACILITATOR})`);
if (network) console.log(`filter: network~="${network}"`);
if (query) console.log(`filter: query~="${query}"`);

for (const it of items) {
const opts = (it.accepts || []).map(a => {
const info = assetInfo(a.asset);
const amt = a.maxAmountRequired ?? a.amount;
return `${human(amt, info.decimals)} ${info.symbol} on ${a.network}`;
});
console.log(`\n• ${it.method || "GET"} ${it.resource}`);
if (it.accepts?.[0]?.description) console.log(` ${it.accepts[0].description}`);
console.log(` pay: ${opts.join(" | ") || "(no accepts listed)"}`);
if (it.accepts?.[0]?.payTo) console.log(` payTo: ${it.accepts[0].payTo}`);
}

console.log(`\nTo call + pay one of these, use the companion \`x402\` skill.`);
Loading