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

@cipherpay/x402

v0.5.0

Published

Accept private Zcash payments on any API via x402, MPP, and session protocols. CipherPay is the Zcash facilitator.

Readme

@cipherpay/x402

Accept private Zcash payments on any API via x402 and MPP protocols. One middleware. Fully shielded. No buyer data exposed.

CipherPay is the Zcash facilitator for agentic payments — the only way to accept shielded ZEC in the HTTP 402 flow.

Why

Every x402 payment on Base, Solana, or Polygon is public. Anyone can see which APIs an agent is using, how often, and how much it's spending.

Zcash shielded payments make all of that invisible. The buyer (human or AI agent) reveals nothing — no identity, no balance, no transaction history.

Install

npm install @cipherpay/x402

Quick Start (Express)

import express from 'express';
import { zcashPaywall } from '@cipherpay/x402/express';

const app = express();

app.use('/api/premium', zcashPaywall({
  amount: 0.001,          // ZEC per request
  address: 'u1abc...',    // Your Zcash Unified Address
  apiKey: 'cpay_sk_...',  // CipherPay API key
}));

app.get('/api/premium/data', (req, res) => {
  res.json({ temperature: 18, conditions: 'partly cloudy' });
});

app.listen(3000);

Protocol Support

The middleware supports three payment methods — all handled transparently:

| Method | Header | Use case | |--------|--------|----------| | x402 | PAYMENT-SIGNATURE | Standard x402 per-request payments | | MPP | Authorization: Payment | Machine Payments Protocol | | Sessions | Authorization: Bearer cps_... | Prepaid credit — pay once, use many times |

By default, the middleware advertises both x402 and MPP challenge formats in 402 responses and accepts credentials from either protocol. Sessions are always accepted when a valid bearer token is present.

How It Works

Agent                           Your API                    CipherPay
  │                               │                            │
  │  GET /api/premium/data        │                            │
  │──────────────────────────────>│                            │
  │                               │                            │
  │  402 Payment Required         │                            │
  │  PAYMENT-REQUIRED: base64     │  (x402 challenge)          │
  │  WWW-Authenticate: Payment    │  (MPP challenge)           │
  │<──────────────────────────────│                            │
  │                               │                            │
  │  (agent sends shielded ZEC)   │                            │
  │                               │                            │
  │  GET /api/premium/data        │                            │
  │  Authorization: Payment ...   │  (or PAYMENT-SIGNATURE)    │
  │──────────────────────────────>│                            │
  │                               │  POST /api/x402/verify     │
  │                               │───────────────────────────>│
  │                               │  { valid: true }           │
  │                               │<───────────────────────────│
  │                               │                            │
  │  200 OK                       │                            │
  │<──────────────────────────────│                            │

Session flow (prepaid credit)

Agent                           Your API                    CipherPay
  │                               │                            │
  │  POST /api/sessions/open      │                            │
  │  { txid, merchant_id }        │───────────────────────────>│
  │                               │  { bearer_token: cps_... } │
  │<──────────────────────────────│<───────────────────────────│
  │                               │                            │
  │  GET /api/premium/data        │                            │
  │  Authorization: Bearer cps_.. │                            │
  │──────────────────────────────>│  GET /sessions/validate    │
  │                               │───────────────────────────>│
  │                               │  { valid, balance }        │
  │  200 OK                       │<───────────────────────────│
  │  X-Session-Balance: 49000     │                            │
  │<──────────────────────────────│                            │

Replay Protection

By default, the middleware rejects transactions that have already been verified. A replayed txid returns 402 with "error": "payment_replayed".

app.use('/api/premium', zcashPaywall({
  amount: 0.001,
  address: 'u1abc...',
  apiKey: 'cpay_sk_...',
  rejectReplays: true,      // default — each txid works once
}));

Set rejectReplays: false for endpoints where the same transaction should grant repeated access (e.g., downloading a file multiple times after purchase).

Protocol Compatibility

| Feature | x402 | MPP | Sessions | |---------|------|-----|----------| | Challenge header | PAYMENT-REQUIRED | WWW-Authenticate: Payment | — | | Credential header | PAYMENT-SIGNATURE | Authorization: Payment | Authorization: Bearer cps_... | | Settlement header | PAYMENT-RESPONSE | Payment-Receipt | X-Session-Balance | | Replay protection | Yes | Yes | N/A (balance-based) | | Per-request cost | Full amount | Full amount | cost_per_request from session |

Framework-Agnostic Usage

import { createPaywall } from '@cipherpay/x402';

const paywall = createPaywall({
  amount: 0.001,
  address: 'u1abc...',
  apiKey: 'cpay_sk_...',
});

// Use with any framework that has (req, res, next)
server.use('/paid', (req, res, next) => paywall(req, res, next));

Dynamic Pricing

import { zcashPaywall } from '@cipherpay/x402/express';

app.use('/api/ai', zcashPaywall({
  address: 'u1abc...',
  apiKey: 'cpay_sk_...',
  amount: 0,
  getAmount: (req) => {
    if (req.url.includes('gpt-4')) return 0.01;
    if (req.url.includes('gpt-3')) return 0.001;
    return 0.0005;
  },
  description: 'AI inference — price varies by model',
}));

Standalone Verification

import { verifyPayment } from '@cipherpay/x402';

const result = await verifyPayment(
  '7f3a9b2c...',       // transaction ID
  0.001,               // expected ZEC amount
  'cpay_sk_...',       // CipherPay API key
);

if (result.valid) {
  console.log(`Received ${result.received_zec} ZEC`);
}

Configuration

| Option | Type | Required | Description | |--------|------|----------|-------------| | amount | number | Yes* | ZEC amount per request | | address | string | Yes | Zcash Unified Address | | apiKey | string | Yes | CipherPay API key (cpay_sk_...) | | facilitatorUrl | string | No | CipherPay URL (default: https://api.cipherpay.app) | | network | string | No | CAIP-2 identifier (default: zcash:mainnet) | | description | string | No | Human-readable description in 402 response | | maxTimeoutSeconds | number | No | Verification timeout (default: 120) | | getAmount | function | No | Dynamic pricing function (overrides amount) | | protocol | 'x402' \| 'mpp' \| 'both' | No | Which challenge format(s) to advertise (default: 'both') | | rejectReplays | boolean | No | Reject previously-verified txids (default: true) |

*Required unless getAmount is provided.

402 Response Format (x402 v2)

{
  "x402Version": 2,
  "resource": {
    "url": "/api/premium/data",
    "description": "Premium weather data"
  },
  "accepts": [
    {
      "scheme": "exact",
      "network": "zcash:mainnet",
      "asset": "ZEC",
      "amount": "100000",
      "payTo": "u1abc...",
      "maxTimeoutSeconds": 120,
      "extra": {}
    }
  ]
}

For AI Agent Developers

AI agents can pay for gated APIs using a shielded Zcash wallet. Three options:

Per-request (x402 or MPP): Agent receives a 402, sends shielded ZEC, retries with the txid. Simple, one payment per request.

Sessions (prepaid credit): Agent sends a deposit transaction, receives a bearer token (cps_...), and uses it for subsequent requests. Balance is deducted automatically. Best for high-frequency API usage.

Every payment is fully encrypted on the Zcash blockchain. No observer can see what API the agent called, how much it paid, or how often.

Get a CipherPay Account

  1. Go to cipherpay.app and register as a merchant.
  2. Provide your Zcash Unified Full Viewing Key (read-only, cannot spend funds).
  3. Get your API key (cpay_sk_...).
  4. Use it in the middleware config.

Same account works for both e-commerce (invoices, checkout) and x402 (API monetization).

Links

License

MIT — Atmosphere Labs