コンテンツへスキップ
xobank.cash
01ドキュメント

xobankの上に構築。

BAPARAプロトコル、xo Money API、webhook、rail統合のためのガイド。

02クイックスタート

3ステップでエージェントに課金。

ゼロから10分以内に有料エンドポイントを構築。サーバーが価格を宣言し、クライアントが支払い、ファシリテーターがオンチェーンで決済します。

01

Install the SDK

One package, server and client entrypoints. Works with Express, Fastify, Hono and Next.js route handlers.

terminal
pnpm add @xo/bapara-sdk

# grab a sandbox wallet + testnet USDC
npx bapara init --network base-sepolia
02

Declare a price on your route

Answer 402 with the amount, asset and facilitator. When the retry arrives with an X-Payment header, verify it and serve the response.

server.ts
import { paymentRequired, verifyPayment } from '@xo/bapara-sdk/server';

app.get('/inference', async (req, res) => {
  const pr = paymentRequired({
    amount: '0.002',                       // USDC
    recipient: process.env.WALLET!,
    facilitator: 'https://facilitator.bankai.cash',
  });

  const header = req.headers['x-payment'];
  if (!header) return res.status(402).json(pr);

  const check = await verifyPayment(header, { expect: pr });
  if (!check.ok) return res.status(402).json(pr);

  res.setHeader('X-Payment-Receipt', check.receipt.encoded);
  res.json({ completion: await runModel(req.body) });
});
03

Point your agent at it

The client handles the 402 handshake automatically: sign, retry, collect the receipt. maxAmountUsdc is the hard budget for this call.

agent.ts
import { BaparaClient } from '@xo/bapara-sdk/client';

const client = new BaparaClient(wallet);

const res = await client.fetch('https://api.example.com/inference', {
  method: 'POST',
  maxAmountUsdc: 0.10,
  body: JSON.stringify({ prompt: 'summarize this filing' }),
  onReceipt: (r) => audit.log('settled', r.txHash),
});
verify it works
$ curl -i https://api.example.com/inference
HTTP/1.1 402 Payment Required          # no payment attached
{"amount":"0.002","asset":"USDC","network":"base", ...}

$ npx bapara call https://api.example.com/inference --max 0.10
✓ 200 OK · settled onchain 0x…7f2e · 187ms · receipt saved
BAPARA protocol

x402 + budgets + AP2. Full spec, SDKs and facilitator reference.

quickstart →
xo Money API
soon

Programmatic access to accounts, transfers, cards and webhooks.

Card issuing
soon

Provision physical and virtual cards. Freeze, top-up, PIN.

Rail integrations
soon

PIX, SPEI, SEPA, ACH — with idempotency, retries and receipt formats.

Webhooks
soon

Signed delivery, replay windows, ordered vs unordered streams.

Facilitator reference
soon

Run your own facilitator in Fastify + viem in <200 LOC.