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

@agentpaywall/sdk

v0.3.0

Published

Drop-in USDC micropayment middleware for APIs, settled on Solana.

Readme

@agentpaywall/sdk

npm version License: MIT

Drop-in micropayment middleware for APIs, settled in USDC on Solana.

Add two lines of code to any Express or Next.js API and start earning USDC per call - no billing system, no minimums, no chargebacks.

How it works

Client calls API  ->  No payment?  ->  402 + payment instructions (JSON)
                  ->  Has proof?   ->  Verify on-chain  ->  200 + data
  1. An unpaid request gets a 402 Payment Required response with a JSON body containing the price, recipient wallet, and Solana RPC details.
  2. The client (human or AI agent) sends USDC to the specified wallet on Solana.
  3. The client retries the request with X-Payment-Proof: <solana_tx_signature>.
  4. The middleware verifies the payment on-chain and forwards the request to your handler.

Installation

npm install @agentpaywall/sdk @solana/web3.js @solana/spl-token

Quick Start

Express

import express from 'express';
import { agentPaywall } from '@agentpaywall/sdk';

const app = express();

app.get(
  '/api/data',
  agentPaywall({
    priceUsdc: 0.001,
    recipientWallet: 'YOUR_SOLANA_WALLET',
    apiId: 'your-api-id',
  }),
  (req, res) => {
    res.json({ data: 'premium content' });
  },
);

app.listen(3000);

Next.js (App Router)

import { withAgentPaywall } from '@agentpaywall/sdk/nextjs';

const config = {
  priceUsdc: 0.001,
  recipientWallet: 'YOUR_SOLANA_WALLET',
  apiId: 'your-api-id',
};

export const GET = withAgentPaywall(config, async (request) => {
  return Response.json({ data: 'premium content' });
});

Fastify

import Fastify from 'fastify';
import { verifyUSDCPayment, build402Response } from '@agentpaywall/sdk';

const config = {
  priceUsdc: 0.001,
  recipientWallet: 'YOUR_SOLANA_WALLET',
  apiId: 'your-api-id',
};

const fastify = Fastify();

fastify.addHook('preHandler', async (request, reply) => {
  const proof = request.headers['x-payment-proof'];
  if (!proof) {
    return reply.status(402).send(build402Response(config));
  }

  const result = await verifyUSDCPayment({
    txSignature: proof as string,
    expectedRecipient: config.recipientWallet,
    expectedAmountUsdc: config.priceUsdc,
    rpcUrl: 'https://api.devnet.solana.com',
  });

  if (!result.valid) {
    return reply.status(402).send({
      ...build402Response(config),
      verificationError: result.error,
    });
  }
});

fastify.get('/api/data', async () => {
  return { data: 'premium content' };
});

fastify.listen({ port: 3000 });

Configuration

| Option | Type | Required | Default | Description | |--------|------|----------|---------|-------------| | priceUsdc | number | Yes | - | Price in USDC per API call (e.g. 0.001) | | recipientWallet | string | Yes | - | Solana wallet (base58) that receives USDC | | apiId | string | Yes | - | API ID for tracking and analytics | | platformApiKey | string | No | - | API key to report transactions to the dashboard | | rpcUrl | string | No | devnet | Solana RPC endpoint | | usdcMintAddress | string | No | auto | USDC mint (auto-detected from RPC URL) | | network | 'devnet' \| 'mainnet-beta' | No | 'devnet' | Solana network |

API Reference

agentPaywall(config)

Express middleware. Returns 402 for unpaid requests, verifies payment, then calls next().

withAgentPaywall(config, handler)

Next.js App Router wrapper. Returns 402 for unpaid requests, verifies payment, then calls your handler.

verifyUSDCPayment(params)

Low-level verification function. Checks a Solana transaction for a USDC transfer matching the expected amount and recipient. Never throws - returns { valid: false, error } on failure.

build402Response(config)

Builds the standard 402 JSON response payload with payment instructions.

recordTransaction(params)

Fire-and-forget function that reports verified payments to the AgentPaywall dashboard.

402 Response Format

{
  "error": "Payment Required",
  "code": "PAYMENT_REQUIRED",
  "paymentDetails": {
    "network": "solana",
    "currency": "USDC",
    "amount": 0.001,
    "recipient": "YOUR_WALLET",
    "memo": "your-api-id",
    "usdcMintAddress": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
    "rpcUrl": "https://api.devnet.solana.com"
  },
  "instructions": "Send exactly 0.001 USDC on Solana to YOUR_WALLET...",
  "example": {
    "header": "X-Payment-Proof",
    "value": "<solana_transaction_signature>",
    "description": "Add the Solana transaction signature as a header after payment"
  }
}

Why AgentPaywall?

| | Traditional Billing | AgentPaywall | |---|---|---| | Setup | Stripe account, webhooks, invoicing | 2 lines of middleware | | Minimums | $0.50+ per charge | $0.000001 (6 decimal USDC) | | Fees | 2.9% + $0.30 | ~$0.00025/tx (Solana fee) | | Chargebacks | Yes | Impossible (on-chain) | | AI agents | Can't sign up for Stripe | Parse JSON, pay, retry | | Settlement | Days/weeks | ~400ms | | KYC | Required | Permissionless |

Dashboard

Track earnings, API calls, and transactions in real time at agentpaywall.vercel.app.

License

MIT