SDKs and tools
An honest inventory, because a missing package is worse than a documented gap.
| Side | What exists today | Status |
|---|---|---|
| Buyer | xdcai CLI on npm | Published, command line only |
| Buyer | MCP connector at api.xdcai.tech/mcp | Live |
| Buyer | Raw HTTP plus any EVM signing library | Works everywhere |
| Seller | Raw HTTP against the facilitator | Works today, see the seller guide |
| Seller | Gateway (no payment code at all) | Live, see Gateway |
| Seller | @xdcai/x402-seller middleware | Not published to npm yet |
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" }
}
}
Your own code
If you would rather not shell out, 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
Today: 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.
Coming: @xdcai/x402-seller
The facilitator team is preparing a TypeScript middleware that wraps the 402 response, verification, settlement and the polling loop into one call:
// Not installable yet. Shown so you can see where this is heading.
import { paymentMiddleware } 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!,
network: "eip155:50",
tokenName: "USDC",
tokenVersion: "2",
},
},
}));
A hono binding (honoPaymentMiddleware) is planned alongside it. The environment variables are the same ones you already set, so moving from raw HTTP to the middleware later is a small change.
:::warning Do not add it to package.json yet
npm install @xdcai/x402-seller currently fails: the package is not on the registry. Build against the raw endpoints until it ships.
:::
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.