SDKs and tools
An honest inventory of every way to pay or get paid.
| Side | What exists today | Status |
|---|---|---|
| Buyer | xdcai CLI on npm | Published, command line only |
| Buyer | MCP connector at api.xdcai.tech/mcp | Live |
| Buyer | @xdcai/x402-buyer package | Published, 1.0.0-rc.2 |
| Buyer | Raw HTTP plus any EVM signing library | Works everywhere |
| Seller | @xdcai/x402-seller middleware | Published, 1.0.0-rc.1 |
| Seller | Raw HTTP against the facilitator | Works today, see the seller guide |
| Seller | Gateway (no payment code at all) | Live, see Gateway |
The @xdcai/x402-seller and @xdcai/x402-buyer packages are published by the facilitator team (Apache-2.0). Both are release candidates, so pin an exact version rather than a floating range: 1.0.0-rc.2 for the buyer, 1.0.0-rc.1 for the seller. npm latest still points at rc.1 for both, so a range gives you the older buyer package.
For buyers
The CLI
npm install -g xdcai # or run it per call with npx
npx xdcai call https://provider.example/x402/endpoint
The package ships a binary, not a library. It has no main, no exports and no type declarations, so import { call } from "xdcai" does not work. That is deliberate for now: the CLI is self-contained so an agent with a shell can use it without a build step.
To drive it from code, run it as a process and parse stdout. Every command prints exactly one JSON object there, with prompts and logs on stderr:
import { execFile } from "node:child_process";
import { promisify } from "node:util";
const run = promisify(execFile);
const { stdout } = await run("npx", ["xdcai", "call", url, "--data", JSON.stringify(body)]);
const result = JSON.parse(stdout); // { paid, txHash, body, ... }
The MCP connector
For an assistant rather than a script. One config entry gives it wallet, marketplace search, paid calls and history:
{
"mcpServers": {
"xdcai": { "url": "https://api.xdcai.tech/mcp" }
}
}
The buyer SDK
For your own Node agent, @xdcai/x402-buyer gives you a payment-aware fetch with a spending policy (max amount, allowed network, asset and payee) and an idempotent payment-intent store. You bring a signer, not a key. See the Buyer SDK tab in the buyer guide.
npm install @xdcai/x402-buyer@1.0.0-rc.2
Your own code, from scratch
If you would rather not take a dependency, a paid call is two HTTP requests and one signature. The buyer guide has the complete example with viem. Any library that can sign EIP-712 typed data works: ethers, web3.js, or a wallet SDK.
For sellers
The seller SDK
@xdcai/x402-seller is a TypeScript middleware that wraps the 402 response, verification, settlement and the polling loop into one call, for Express or Hono on Node. See the SDK middleware tab in the seller guide.
npm install @xdcai/x402-seller@1.0.0-rc.1
import { paymentMiddleware, XDC_USDC } from "@xdcai/x402-seller";
app.use(paymentMiddleware({
facilitatorUrl: process.env.FACILITATOR_URL!,
facilitatorApiKey: process.env.FACILITATOR_API_KEY!,
seller: { receiver: process.env.SELLER_RECEIVER_ADDRESS! },
routes: {
"GET /api/data": {
price: "10000",
asset: process.env.TOKEN_ASSET ?? XDC_USDC.asset,
network: XDC_USDC.network,
tokenName: XDC_USDC.eip712.name,
tokenVersion: XDC_USDC.eip712.version,
},
},
}));
Raw HTTP
Three endpoints, one header. The seller guide walks through all of it, and there is nothing to install: your server already has fetch.
If you do not want to write any of it
The gateway is the shortest path: point it at your existing API, set prices per route, and it does the 402, the verification and the settlement. No key, no credits, no polling, and your service gets listed in the marketplace.