npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cspr402

v0.4.10

Published

CSPR402 SDK and CLI for Casper payment verification and simulated virtual cards

Readme

cspr402

Simulated virtual cards for AI agents — pay with native CSPR (or mockUSDC via CEP-18) on Casper mainnet, get a virtual card number, CVV, and expiry after the deploy is verified. The active MVP path is Casper mainnet CSPR order creation and deploy verification, with optional mockUSDC CEP-18 test-token payments.

CSPR402 is an x402-inspired API: an AI agent pays on Casper mainnet, the backend verifies the Casper deploy, and returns a simulated virtual card. This SDK lets agents create an order, submit a Casper native CSPR transfer, and receive virtual card details programmatically — all in one call.

cspr402.xyz is the dashboard and docs surface.

Install

npm install cspr402

Requires Node.js 18 or newer (the SDK uses native fetch, ReadableStream, and WebCrypto).

Quick start

import { purchaseCardCasper, getCasperBalance } from 'cspr402';

// 1. Configure or load your Casper mainnet agent key. Idempotent.
const address = setupCasperAgent('my-agent');
console.log('Fund this Casper mainnet public key:', address);

// 2. Pause here until the address has mainnet CSPR. Re-run to check:
const bal = await getCasperBalance('my-agent');
console.log(`CSPR: ${bal.cspr}  mockUSDC: ${bal.mockUsdc}`);

// 3. Purchase a card — only do this when the user explicitly asks.
const card = await purchaseCardCasper({
  apiKey: process.env.CARDS402_API_KEY!,
  agentName: 'my-agent',
  amountUsdc: '10.00',
  paymentAsset: 'cspr', // or 'mock_usdc' (CEP-18 test token)
});

console.log(card.number, card.cvv, card.expiry);

purchaseCardCasper handles the whole flow:

  1. POST /v1/orders with the amount
  2. Sign + submit the Casper native CSPR (or mockUSDC CEP-18) transfer from your agent key
  3. Subscribe to the SSE stream at /v1/orders/:id/stream
  4. Return the virtual card details as soon as the ready event arrives (deploy verified)

No polling loops, no webhook endpoint required.

Funding your wallet

Casper mainnet accounts are usable as soon as they hold CSPR:

  • Pay with native CSPR: send enough mainnet CSPR to cover the order at the current CSPR/USD rate (shown in payment.cspr.amount when you create an order). Fund from an exchange — Casper mainnet has no faucet.
  • Pay with mockUSDC (CEP-18): a Casper mainnet mock token rail, not official USDC. Only use it once the backend has a deployed mockUSDC CEP-18 package hash configured and the operator has funded you with the mock token.

Step-by-step API (for more control)

import { CSPR402Client } from 'cspr402';

const client = new CSPR402Client({
  apiKey: process.env.CARDS402_API_KEY!,
  // baseUrl defaults to https://api.cspr402.xyz/v1
});

// Create the order
const order = await client.createOrder({ amount_usdc: '10.00' });
console.log(
  `Pay ${order.payment.cspr.amount} CSPR to ${order.payment.recipient_public_key} (transfer_id ${order.payment.transfer_id})`,
);

// ... submit the Casper native transfer yourself, then verify:
await client.verifyCasperPayment(order.order_id, deployHash, { senderPublicKey });

// Wait for delivery (uses SSE under the hood, with polling fallback)
const card = await client.waitForCard(order.order_id, { timeoutMs: 120000 });
console.log(card.number, card.cvv, card.expiry);

Casper mainnet flow (mockUSDC CEP-18)

const mockUsdcOrder = await client.createOrder({
  amount_usdc: '10.00',
  payment_asset: 'mock_usdc_cep18',
  payer_public_key: senderPublicKey,
});
// Submit mockUsdcOrder.payment as a CEP-18 transfer, then verify with the same method.
await client.verifyCasperPayment(mockUsdcOrder.order_id, deployHash, { senderPublicKey });

mock_usdc_cep18 is a Casper mainnet mock token rail for demos, not official USDC.

MCP server — for Claude Desktop, Cursor, and other MCP clients

Add to your client's mcpServers config:

{
  "mcpServers": {
    "cspr402": {
      "command": "npx",
      "args": ["-y", "cspr402"],
      "env": { "CARDS402_API_KEY": "cards402_<your key>" }
    }
  }
}

The MCP server exposes four tools: setup_wallet, check_budget, check_order, and purchase_vcc.

Error handling

All SDK errors inherit from CSPR402Error. Typed subclasses let you react to specific failure modes:

import {
  CSPR402Error,
  AuthError,
  SpendLimitError,
  RateLimitError,
  ServiceUnavailableError,
  InvalidAmountError,
  OrderFailedError,
  WaitTimeoutError,
} from 'cspr402';

try {
  const card = await purchaseCardCasper({ ... });
} catch (err) {
  if (err instanceof SpendLimitError) { /* cap reached — ask owner to raise */ }
  else if (err instanceof OrderFailedError) { /* check err.refund for refund tx */ }
  else if (err instanceof WaitTimeoutError) { /* network flake or stalled fulfillment */ }
  else if (err instanceof AuthError) { /* bad key */ }
}

Keeping card details safe

purchaseCardCasper returns the virtual card PAN, CVV, and expiry as plain strings. Treat them as secrets. Don't log them, don't write them to disk, don't send them to observability pipelines unless those pipelines are explicitly PCI-compliant.

Links

License

MIT — see LICENSE.