Ten lines to accept any coin.
A dependency-free TypeScript SDK and a REST API. Test with a sandbox account (secret key sk_test_…), then switch to live keys: nothing else changes.
Your secret key stays on your server. Amounts are in dollars; the customer pays in any coin and you receive exactly this amount.
import { Cascade } from "@cascade/sdk/server";
const cascade = new Cascade({ apiKey: process.env.CASCADE_SECRET_KEY!, baseUrl: "https://<your-cascade-host>" });
const session = await cascade.checkout.create(
{ amount: "25.00", description: "Stoneware mug", reference: order.id },
{ idempotencyKey: order.id },
);A modal on your page, or redirect to session.url. Wallet payments, QR codes and deposit addresses are handled for you.
import { openCheckout } from "@cascade/sdk/browser";
openCheckout({ sessionUrl: session.url, onPaid: () => showThanks() });Trust the webhook, never the browser. Every event is HMAC-signed with a timestamp.
import { verifyWebhook } from "@cascade/sdk/webhooks";
const event = await verifyWebhook(rawBody, req.headers["cascade-signature"], process.env.CASCADE_WEBHOOK_SECRET!);
if (event.type === "checkout.session.completed") ship(event.data.session.reference);Hosted invoices with line items, plans billed every period, prepaid periods, customers.
const inv = await cascade.invoices.create({ customer: { name: "Fieldwork Café" }, items: [{ description: "Mug", quantity: 24, unitAmount: "18.00" }] });
const plan = await cascade.plans.create({ name: "Mug of the month", amount: "12.00", interval: "month" });
await cascade.subscriptions.create({ planId: plan.id, customer: { name: "Ines" }, prepaidPeriods: 3 });Unpaid requests get HTTP 402 with payment options; agents pay in any coin, or from an on-chain budget on NEAR.
import { x402Guard } from "@cascade/sdk/x402";
const guard = x402Guard(cascade, { price: "0.10", description: "One forecast" });
export async function GET(req: Request) {
const g = await guard(req);
return g.paid ? Response.json(forecast(), { headers: g.headers }) : g.response;
}Run your account from Claude, Cursor or any MCP client, and let agents pay x402 APIs from a budget with limits the contract enforces.
claude mcp add cascade --env CASCADE_URL=https://<your-cascade-host> \ --env CASCADE_SECRET_KEY=rk_live_… -- npx tsx packages/mcp/src/main.ts
Authenticate with Authorization: Bearer sk_…. Read-only keys can call every GET. Idempotency: send Idempotency-Key on creates.
| POST | /v1/checkout/sessions | Create a session (amount in USDC base units) |
| GET | /v1/checkout/sessions/:id | Retrieve a session |
| POST | /v1/checkout/sessions/:id/refunds | Refund in the customer's coin and chain |
| POST | /v1/invoices | Create a hosted invoice |
| POST | /v1/plans · /v1/subscriptions | Recurring billing |
| GET | /v1/customers | Customers with lifetime totals |
| POST | /v1/x402/prepare · /v1/x402/settle | Agent payments (used by x402Guard) |
| GET | /v1/merchant/payouts · escrows · agents | Money out, read from the chain |
| POST | /v1/merchant/keys | Read-only keys (rk_) for your team |
| POST | /v1/merchant/payout | Settlement chain (needs your NEAR signature) |
| GET | /v1/reports/ledger.csv | Accounting export |
| Sandbox | Live | |
|---|---|---|
| Network | NEAR testnet | NEAR mainnet |
| Customer payments | Simulated swap, real contracts and receipts | Real, through NEAR Intents (1Click) |
| Keys | sk_test_ / rk_test_ | sk_live_ / rk_live_ |
| Access | Instant, at /start | After a short review |