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

x402-kit-agent

v0.1.0

Published

HTTP interceptor for AI agents to auto-pay x402 paywalls

Downloads

101

Readme

@x402-kit/agent

HTTP interceptor for AI agents to auto-pay x402 crypto paywalls. Part of x402-kit.

Your agent makes HTTP requests as usual. When a server returns HTTP 402 with x402 payment requirements, this interceptor automatically checks your spending policy, signs a USDC payment, and retries the request.

Installation

npm install @x402-kit/agent

Quick Start

import { createAgentFetch } from "@x402-kit/agent";

const agentFetch = createAgentFetch({
  walletPrivateKey: process.env.X402_WALLET_PRIVATE_KEY as `0x${string}`,
  network: "eip155:8453", // Base mainnet
  policy: {
    maxPerRequest: "1.00",       // Max 1 USDC per request
    maxDailySpend: "10.00",      // Max 10 USDC per day
    allowedNetworks: ["eip155:8453"],
    allowedAssets: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], // USDC on Base
    requireHumanApproval: false,
  },
  logFilePath: "./payments.jsonl",
});

// Use exactly like fetch — payments happen automatically
const response = await agentFetch("https://api.example.com/premium-data");
const data = await response.json();

How It Works

  1. Agent sends a request to a paywalled endpoint
  2. Server returns HTTP 402 with x402 payment requirements
  3. createAgentFetch parses the requirements (amount, network, asset)
  4. Policy engine checks: amount within limits? Network allowed? Domain allowed?
  5. If approved: signs an EIP-3009 USDC transfer authorization
  6. Retries the request with the signed payment in X-PAYMENT header
  7. Logs the payment event to a JSONL file

Configuration

| Option | Type | Required | Description | |--------|------|----------|-------------| | walletPrivateKey | Hex | Yes | Wallet private key (0x...) with USDC balance | | network | Network | Yes | CAIP-2 network ID (e.g., "eip155:8453" for Base) | | policy | X402Policy | Yes | Spending rules (see @x402-kit/shared) | | logFilePath? | string | No | Path for payment log JSONL file | | spendFilePath? | string | No | Path for daily spend persistence | | rpcUrl? | string | No | Custom RPC URL (defaults to public RPC) | | tokenDecimals? | number | No | Token decimals (default: 6 for USDC) |

Testnet Usage

const agentFetch = createAgentFetch({
  walletPrivateKey: process.env.X402_WALLET_PRIVATE_KEY as `0x${string}`,
  network: "eip155:84532", // Base Sepolia testnet
  policy: {
    maxPerRequest: "0.05",
    maxDailySpend: "1.00",
    allowedNetworks: ["eip155:84532"],
    allowedAssets: ["0x036CbD53842c5426634e7929541eC2318f3dCF7e"], // USDC on Base Sepolia
    requireHumanApproval: false,
  },
});

Get testnet USDC from Circle Faucet (select Base Sepolia, USDC).

Re-exports

For users who want the bare x402 client without the policy layer:

import { wrapFetchWithPayment } from "@x402-kit/agent";

License

MIT