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

@opencardcode/opencard-sdk

v2.0.1

Published

Client SDK for OpenCard — create virtual cards with USDC payments via x402

Readme

@opencardcode/opencard-sdk

Client SDK for OpenCard — create virtual prepaid cards with USDC payments via the x402 protocol.

Solana first. Also supports Base.

Install

npm install @opencardcode/opencard-sdk @solana/web3.js

Quick Start (Solana)

import { OpenCardClient } from '@opencardcode/opencard-sdk';

const client = new OpenCardClient({
  solanaPrivateKey: 'your-base58-private-key',  // or solanaKeypair
  network: 'solana',  // default
});

// One line — SDK handles payment automatically
const result = await client.createCard({
  amount: 10,               // $10 card
  nameOnCard: 'AI AGENT',
  email: '[email protected]',
});

console.log(result.order);  // { cardId, status: 'processing', ... }
// Card details delivered via webhook (5-15 min)

Quick Start (Base)

import { OpenCardClient } from '@opencardcode/opencard-sdk';

const client = new OpenCardClient({
  privateKey: '0x...',  // Base wallet with USDC
  network: 'base',
});

const result = await client.createCard({
  amount: 50,
  nameOnCard: 'AI AGENT',
  email: '[email protected]',
});

Configuration

| Option | Type | Required | Description | |--------|------|----------|-------------| | network | "solana" \| "base" | No | Payment network (default: "solana") | | solanaPrivateKey | string | One of | Base58 Solana private key | | solanaKeypair | Keypair | One of | @solana/web3.js Keypair instance | | solanaRpcUrl | string | No | Solana RPC URL (default: mainnet-beta) | | privateKey | 0x${string} | One of | EVM hex private key (for Base) | | walletClient | WalletClient | One of | viem WalletClient (for Base) | | rpcUrl | string | No | Base RPC URL | | baseUrl | string | No | API URL (default: https://opencard.declawds.fun) | | timeout | number | No | Request timeout in ms (default: 60000) |

API

client.createCard(params): Promise<CardResult>

Create a virtual card. SDK handles x402 payment automatically.

const result = await client.createCard({
  amount: 10,               // 10 | 25 | 50 | 100 | 200 | 500
  nameOnCard: 'AI AGENT',
  email: '[email protected]',
});

Note: Card delivery is asynchronous (5-15 minutes). Include a webhookUrl in your request to receive card details when ready.

client.getTiers(): Promise<TiersResponse>

Get pricing tiers and fee breakdown (no payment required).

client.health(): Promise<{ status: string }>

Check if the OpenCard API is reachable.

client.address: string

The wallet address being used for payments.

client.paymentNetwork: "solana" | "base"

The configured payment network.

Error Handling

import {
  OpenCardClient,
  InsufficientBalanceError,
  PaymentError,
  ApiError,
  TimeoutError,
  ConfigError,
} from '@opencardcode/opencard-sdk';

try {
  const result = await client.createCard({ ... });
} catch (error) {
  if (error instanceof InsufficientBalanceError) {
    console.log(`Need ${error.required}, have ${error.available}`);
  } else if (error instanceof PaymentError) {
    console.log(`Payment failed: ${error.message}`);
  } else if (error instanceof ConfigError) {
    console.log(`Configuration error: ${error.message}`);
  } else if (error instanceof ApiError) {
    console.log(`Server error ${error.status}:`, error.body);
  } else if (error instanceof TimeoutError) {
    console.log('Request timed out');
  }
}

How It Works

Your Code          SDK                    OpenCard API          Chain (Solana/Base)
   |                |                         |                    |
   |-- createCard ->|                         |                    |
   |                |--- POST /create/tier -->|                    |
   |                |<-- 402 + challenge -----|                    |
   |                |                         |                    |
   |                |--- USDC.transfer() -----|-------- tx ------->|
   |                |<-- txHash --------------|-------- receipt ---|
   |                |                         |                    |
   |                |--- POST + X-Payment --->|                    |
   |                |<-- 202 + order status --|                    |
   |<- CardResult --|                         |                    |

Card details are delivered asynchronously via webhook (5-15 minutes).

Pricing

| Card | Cost (USDC) | |------|-------------| | $10 | ~$11.80 | | $25 | ~$28.00 | | $50 | ~$55.00 | | $100 | ~$109.00 | | $200 | ~$217.00 | | $500 | ~$541.00 |

Prices are estimates. Actual cost from Trocador may vary slightly.

License

MIT