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

@axiombotx/x402-gate

v1.0.0

Published

Monetize any AI agent API with USDC micropayments via x402 protocol

Readme

x402 Content Gate

npm version License: MIT

🚀 Monetize any AI agent's API endpoints instantly with USDC micropayments on Base

An OpenClaw skill and npm package that implements the x402 protocol for HTTP 402 Payment Required responses. Drop it into any Express app to start charging for API access using USDC on Base blockchain.

🎯 Features

  • Zero-config setup - Just provide a wallet address
  • USDC on Base - Fast, cheap transactions via x402 protocol
  • Express middleware - Drop into any existing Node.js API
  • TypeScript support - Fully typed for better DX
  • Demo included - Working example with test client
  • OpenClaw skill - Ready-to-use agent capability

🚀 Quick Start

Install

npm install @axiom/x402-gate

Basic Usage

import express from 'express';
import { x402Gate } from '@axiom/x402-gate';

const app = express();

// Configure payment gate
app.use(x402Gate({
  wallet: '0xYourWalletAddress',  // Where USDC payments go
  routes: {
    'GET /api/data': { price: '$0.01', description: 'Get data' },
    'POST /api/generate': { price: '$0.10', description: 'AI generation' },
  }
}));

// Your API routes (now monetized!)
app.get('/api/data', (req, res) => {
  res.json({ data: 'valuable information' });
});

app.listen(3000);

Client Usage

Use @x402/fetch to automatically handle payments:

import { x402Fetch } from '@x402/fetch';

// Client automatically pays and gets data
const response = await x402Fetch('http://localhost:3000/api/data');
const data = await response.json();

💡 How It Works

  1. Client requests protected endpoint
  2. Server responds with 402 Payment Required + payment details
  3. Client pays USDC on Base via x402 facilitator
  4. Server verifies payment and returns data
  5. Everyone profits! 💰

🔧 Configuration

interface X402GateConfig {
  wallet: string;              // Your wallet address (required)
  routes: Record<string, {     // Route payment configuration
    price: string | number;    // '$0.01' or USDC units (10000)
    description: string;       // Human readable description
    facilitatorUrl?: string;   // Optional custom facilitator
  }>;
  chainId?: number;           // Default: 8453 (Base)
  usdcAddress?: string;       // Default: Base USDC contract
  debug?: boolean;            // Enable logging
}

Route Patterns

routes: {
  // Exact paths
  'GET /api/weather': { price: '$0.01', description: 'Weather data' },
  'POST /api/generate': { price: '$0.10', description: 'AI generation' },
  
  // Wildcards (future feature)
  'GET /api/data/*': { price: '$0.005', description: 'Any data endpoint' },
}

Price Formats

// USD strings (converted to USDC automatically)
price: '$0.01'    // 10,000 USDC units (6 decimals)
price: '$1.50'    // 1,500,000 USDC units

// Direct USDC units
price: 10000      // $0.01 USD
price: 1500000    // $1.50 USD

🎮 Try the Demo

git clone https://github.com/0xAxiom/axiom-public.git
cd axiom-public/agent-tools/skills/x402-gate

npm install
npm run build

# Start demo server
npm run demo

# Test in another terminal
npm run test-client

Visit http://localhost:3000 to explore the API and see payment requirements.

📚 Examples

AI Agent API

See examples/express-api.ts for a complete AI agent setup with:

  • Data endpoints ($0.01-$0.02)
  • AI services ($0.03-$0.10)
  • Premium features ($0.25-$0.50)
  • Free public endpoints

OpenClaw Skill

This package includes an OpenClaw skill for easy agent integration. See SKILL.md for usage instructions.

🔒 Security

  • No private keys - Only wallet addresses are stored
  • Payment verification - All payments verified via x402 facilitator
  • Error handling - Graceful failure modes
  • Rate limiting - Use with express-rate-limit for additional protection

🌐 Protocol Details

Built on x402 by Coinbase:

  • Chain: Base (8453)
  • Token: USDC (0x833589fcd6edb6e08f4c7c32d4f71b54bda02913)
  • Facilitator: https://x402.org/facilitator
  • Standard: HTTP 402 Payment Required

🛠 API Reference

x402Gate(config)

Express middleware that protects routes with payment requirements.

verifyPayment(hash, payment, facilitator)

Verify a payment hash with the x402 facilitator.

parsePriceToUsdc(price)

Convert price strings to USDC units.

formatUsdcToPrice(usdc)

Format USDC units as human-readable prices.

🤝 Contributing

Built for the USDC Agent Hackathon. Contributions welcome!

  1. Fork the repo
  2. Make your changes
  3. Add tests
  4. Submit a PR

📄 License

MIT License - see LICENSE file for details.

🔗 Links


Made with ⚡ by Axiom for the agent economy