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 🙏

© 2025 – Pkg Stats / Ryan Hefner

x402-npm

v0.1.3

Published

npm CLI wrapper with x402 payment support for monetized packages

Readme

x402-npm

A drop-in npm CLI replacement with built-in x402 payment support for monetized packages.

Installation

npm install -g x402-npm

Overview

x402-npm is a drop-in replacement for npm that enables seamless micropayments for npm packages using the x402 payment protocol. It works with the x402 npm registry to allow developers to:

  • Install any npm package - works with all packages from npmjs.org
  • Install paid packages with automatic USDC payments on Base network
  • Manage a crypto wallet for package payments
  • Authenticate via email verification

All standard npm commands work exactly as expected. The x402 registry proxies to npmjs.org, so you get full access to the entire npm ecosystem plus paid x402 packages.

Quick Start

# 1. Login (creates a wallet automatically)
x402-npm login

# 2. Fund your wallet with USDC
x402-npm wallet fund

# 3. Install packages (paid packages require confirmation)
x402-npm install some-paid-package

Commands

x402-npm login

Authenticate with the x402 registry using email verification.

x402-npm login

Flow:

  1. Enter your email address
  2. Receive a 6-digit verification code via email
  3. Enter the code to complete login

On first login:

  • A new user account is created
  • A custodial wallet is automatically provisioned on Base network
  • Credentials are saved locally in ~/.x402-npm/session.json

Example:

$ x402-npm login
Enter your email: [email protected]

Sending verification code to [email protected]...
Verification code sent!
Enter verification code: 123456

Verifying...

==================================================
Logged in successfully!
==================================================

User: [email protected]
Wallet: 0x1234...abcd
Network: base

Tip: Run 'x402-npm wallet fund' to add USDC to your wallet

x402-npm logout

Sign out from the x402 registry and clear local session data.

x402-npm logout

Example:

$ x402-npm logout
Logged out from [email protected]

x402-npm whoami

Display current logged-in user and wallet information.

x402-npm whoami

Example:

$ x402-npm whoami
User: [email protected]
Username: developer_abc123
Wallet: 0x1234...abcd
Network: base
Session created: 12/4/2025, 3:45:00 PM

x402-npm install [packages...]

Install packages with x402 payment support.

x402-npm install <package-name> [options]

Aliases: x402-npm i

Options: | Option | Description | |--------|-------------| | -D, --save-dev | Save as dev dependency | | -g, --global | Install globally | | --save-exact | Save exact version | | -y, --yes | Auto-confirm payment (skip confirmation prompt) |

Behavior:

  1. Checks if packages require payment
  2. Shows pricing breakdown for paid packages
  3. Prompts for payment confirmation (unless --yes is used)
  4. Signs payment using your wallet
  5. Downloads packages after payment verification
  6. Runs standard npm install

Example (paid package):

$ x402-npm install premium-lib
Checking package prices...

Packages requiring payment:
  premium-lib: $0.05 USDC
  Total: $0.05 USDC

Logged in as: [email protected]
Wallet: 0x1234...abcd

Proceed with payment of $0.05 USDC? (y/N) y

Processing payments and downloading packages...
  Processing premium-lib...
  Signing payment for premium-lib...
  Downloading premium-lib...
  Paid for premium-lib

Running npm install...

Example (free package from x402 registry):

$ x402-npm install lodash
Checking package prices...

Free packages:
  lodash

Running npm install...

Example (regular npm package - no login required):

$ x402-npm install express react typescript
Checking package prices...

Free packages:
  express
  react
  typescript

Running npm install...

Note: Free packages and standard npm packages don't require login. Only paid x402 packages require authentication.

Example (auto-confirm):

$ x402-npm install premium-lib --yes
Checking package prices...

Packages requiring payment:
  premium-lib: $0.05 USDC
  Total: $0.05 USDC

Auto-confirming payment of $0.05 USDC...
...

x402-npm wallet

Display wallet information and balances.

x402-npm wallet

Example:

$ x402-npm wallet
Wallet Info
===========
Address: 0x1234...abcd
Network: base

Fetching balances...

Balances:
  USDC: $10.50
  ETH:  0.001 ETH

Tip: Run 'x402-npm wallet fund' to add USDC to your wallet

x402-npm wallet fund

Open Coinbase Onramp in your browser to purchase USDC and fund your wallet.

x402-npm wallet fund

Example:

$ x402-npm wallet fund
Generating secure onramp session...
Wallet: 0x1234...abcd
Opening Coinbase Onramp in your browser...

Onramp opened in browser. Complete the purchase to fund your wallet.

Note: If the browser fails to open, you can manually send USDC (on Base network) to your wallet address.


x402-npm wallet export

Display wallet export information.

x402-npm wallet export

Example:

$ x402-npm wallet export

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WARNING: This wallet is managed by Coinbase Developer Platform.
Private keys are securely stored server-side and are not
directly exportable from the CLI.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Wallet Address: 0x1234...abcd
Network: base

To export your private key, visit the CDP dashboard at:
https://portal.cdp.coinbase.com

Passthrough Commands

All other npm commands are passed through to npm directly:

# These work exactly like regular npm
x402-npm publish
x402-npm init
x402-npm run build
x402-npm test
x402-npm update
x402-npm uninstall package-name
# ... any other npm command

Configuration

Environment Variables

| Variable | Description | Default | |----------|-------------|---------| | X402_REGISTRY | Custom registry URL | https://api.x402npmregistry.com |

Example:

export X402_REGISTRY=https://your-registry.example.com
x402-npm login

Session Storage

Session data is stored in ~/.x402-npm/session.json and includes:

  • Authentication token
  • User information
  • Wallet address and network
  • NPM token for registry access

How Payments Work

  1. x402 Protocol: When you request a paid package, the registry returns HTTP 402 (Payment Required) with payment details.

  2. Server-Side Signing: Your wallet is custodial (managed by Coinbase Developer Platform). Payment signatures are generated server-side using your session token.

  3. USDC on Base: Payments are made in USDC on the Base network (Coinbase's L2). Transactions are fast and have minimal gas fees.

  4. Atomic Downloads: Payment is verified before the package tarball is served. No payment = no package.

Publishing Paid Packages

To publish a package to the x402 registry:

# 1. Login to get your auth token
x402-npm login

# 2. Set the x402 registry as your npm registry
npm config set registry https://api.x402npmregistry.com

# 3. Set your auth token (get this from x402-npm whoami or ~/.x402-npm/session.json)
npm config set //api.x402npmregistry.com/:_authToken "YOUR_NPM_TOKEN"

# 4. Publish your package
npm publish

# 5. Set pricing via the web UI
# Visit: https://www.x402npmregistry.com

To get your auth token:

# Option 1: Check your session file
cat ~/.x402-npm/session.json | grep npmToken

# Option 2: The token is shown after login
x402-npm login

Default price for new packages is $0.01 USDC. You can adjust pricing in the web dashboard at www.x402npmregistry.com.

Troubleshooting

"Not logged in" error

Run x402-npm login to authenticate.

"Insufficient balance" error

Run x402-npm wallet fund to add USDC to your wallet.

Package not found

The x402 registry proxies to npmjs.org for packages not published directly. If a package isn't found, it may be a network issue.

Session expired

Run x402-npm logout then x402-npm login to refresh your session.

License

MIT

Links