Kairo

TypeScript SDK

@kairo/x402 — one package for the gateway, agent wallets, KLIK agent checkout and the Swap Agent API. It is not on npm yet; copy it from the KAIRO repository (sdk/x402). Requires viem 2.x.

Exports

  • KairoX402Client — fetch(url, init) handles 402, enforces maxPaymentUnits, signs EIP-3009, retries 202/503 with the same authorization.
  • verifyWebhook(secret, rawBody, header) and verifyPaymentProof(secret, headers) — seller-side checks.
  • KairoAgentApi — chains(), swapQuote().
  • getCheckout(url), payCheckout(client, expected, customer) — refuses to pay if price, recipient or terms hash changed.
  • X402Error — code, status, details.
errors
try { await client.fetch(url); }
catch (e) { if (e instanceof X402Error && e.code === "price_above_limit") { /* ask the owner */ } }