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

nory-x402-middleware

v1.0.0

Published

Add x402 payment paywalls to any API in one line of code. Instant USDC micropayments on Solana.

Readme

nory-x402-middleware

Add x402 payment paywalls to any API in one line of code. Instant USDC micropayments on Solana.

Installation

npm install nory-x402-middleware

Quick Start

Express

import express from 'express';
import { paywall, init } from 'nory-x402-middleware/express';

const app = express();

// Initialize with your wallet address
init({
  walletAddress: 'YOUR_SOLANA_WALLET_ADDRESS'
});

// Add a paywall to any route - 1 cent per request
app.get('/api/premium', paywall({ price: '0.01' }), (req, res) => {
  // Only runs if payment is verified
  console.log('Paid by:', req.payment?.payer);
  res.json({ data: 'premium content' });
});

app.listen(3000);

Next.js (App Router)

// app/api/premium/route.ts
import { createPaywallHandler, init } from 'nory-x402-middleware/next';

init({ walletAddress: 'YOUR_SOLANA_WALLET_ADDRESS' });

export const GET = createPaywallHandler(
  { price: '0.01' },
  async (request, payment) => {
    return Response.json({
      data: 'premium content',
      paidBy: payment.payer
    });
  }
);

Next.js (Pages Router)

// pages/api/premium.ts
import { withPaywall, init } from 'nory-x402-middleware/next';

init({ walletAddress: 'YOUR_SOLANA_WALLET_ADDRESS' });

export default withPaywall({ price: '0.01' }, async (req, res) => {
  res.json({
    data: 'premium content',
    paidBy: req.payment?.payer
  });
});

Configuration

Environment Variables

NORY_WALLET_ADDRESS=your_solana_wallet_address
NORY_API_KEY=your_api_key  # Optional, for analytics
NORY_NETWORK=solana:mainnet  # Default

Programmatic Configuration

import { init } from 'nory-x402-middleware';

init({
  walletAddress: 'YOUR_WALLET',
  apiKey: 'YOUR_API_KEY',  // Optional
  network: 'solana:mainnet',  // Default
  baseUrl: 'https://noryx402.com',  // Default
});

Paywall Options

interface PaywallOptions {
  /** Price in USD (e.g., '0.01' for 1 cent) */
  price: string;
  
  /** Currency (defaults to 'USDC') */
  currency?: string;
  
  /** Custom description for the payment */
  description?: string;
  
  /** Override wallet address for this endpoint */
  walletAddress?: string;
  
  /** Override network for this endpoint */
  network?: string;
}

How It Works

  1. When a request comes without payment, the middleware returns HTTP 402 with payment requirements
  2. The client (AI agent, app, etc.) creates a USDC payment transaction
  3. The client retries with the payment proof in X-Payment header
  4. The middleware verifies the payment and allows access
  5. Payment settles on Solana in ~400ms

Response Format

402 Payment Required

{
  "error": "Payment Required",
  "message": "This endpoint requires a payment of 0.01 USDC",
  "price": "0.01",
  "currency": "USDC",
  "paymentInfo": {
    "x402Version": 2,
    "accepts": [{
      "network": "solana:mainnet",
      "amount": "10000",
      "currency": "USDC",
      "address": "YOUR_WALLET",
      "resource": "/api/premium"
    }],
    "resource": "/api/premium"
  }
}

Links

  • Website: https://noryx402.com
  • Docs: https://noryx402.com/docs
  • MCP Server: https://www.npmjs.com/package/nory-mcp-server
  • x402 Protocol: https://github.com/coinbase/x402

License

MIT