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

@ar-agents/x402

v0.2.0

Published

HTTP 402 agent payments protocol (x402) client + seller helpers + Vercel AI SDK tools. Fetch wrapper that pays on 402 via a pluggable signer, framework-agnostic seller helpers (402 response, verify, settle), and a facilitator client. Edge Runtime compatib

Downloads

85

Readme

@ar-agents/x402

HTTP 402 agent payments protocol (x402) client + seller helpers + Vercel AI SDK tools. Edge Runtime compatible, zero heavy deps. Implements the x402 v1 spec (PaymentRequirements, X-PAYMENT / X-PAYMENT-RESPONSE headers, facilitator /verify + /settle).

Wallets stay outside this package: you wire a signer callback (viem, the Coinbase CDP SDK, anything that can produce a signed PaymentPayload). Without one the package can probe prices but never spend.

Install

pnpm add @ar-agents/x402 ai zod

Buyer: pay-on-402 fetch

import { x402Fetch } from "@ar-agents/x402";

const { response, paid, settlement } = await x402Fetch(
  "https://api.example.com/premium-data",
  { method: "GET" },
  {
    // Your wallet. Receives the selected PaymentRequirements, returns a
    // signed PaymentPayload (for the "exact" scheme: EIP-3009 signature).
    signer: async (requirements) => myViemSigner.sign(requirements),
    // Optional human gate BEFORE money moves.
    onPayment: async (req) =>
      confirm(`Pay ${req.maxAmountRequired} atomic units of ${req.asset}?`),
  },
);

console.log(paid, settlement?.transaction); // true, "0x1234..."

Probe without paying:

import { probePaymentRequirements } from "@ar-agents/x402";
const body = await probePaymentRequirements("https://api.example.com/premium-data");
// null when free; otherwise { x402Version, error, accepts: [...] }

Seller: charge for a route (Web API, Edge ready)

import {
  FacilitatorClient,
  paymentRequiredResponse,
  verifyPayment,
  settleAndRespond,
} from "@ar-agents/x402";

const facilitator = new FacilitatorClient({ baseUrl: "https://x402.org/facilitator" });

const requirements = {
  scheme: "exact",
  network: "base",
  maxAmountRequired: "10000", // atomic units (USDC has 6 decimals)
  asset: "0x...usdc",
  payTo: "0x...you",
  resource: "https://api.example.com/premium-data",
  description: "Access to premium market data",
  maxTimeoutSeconds: 60,
};

export async function GET(request: Request) {
  const result = await verifyPayment(request, requirements, facilitator);
  if (!result.verified) return result.response; // ready-made 402

  const work = Response.json({ data: "premium" });
  return settleAndRespond(result.payload, requirements, facilitator, work);
}

Agent tools (Vercel AI SDK 6)

import { x402Tools, FacilitatorClient } from "@ar-agents/x402";

const tools = x402Tools({
  signer: myViemSigner,
  onPayment: async (req) => askOperator(req), // programmatic HITL gate
  facilitator: new FacilitatorClient({ baseUrl: "https://x402.org/facilitator" }),
});
// x402_get_payment_requirements, x402_paid_fetch, x402_verify_payment

Without a signer, x402_paid_fetch returns { ok: false, code: "unconfigured" } instead of throwing, so the agent can explain the situation.

Scope

  • v1 of the protocol only (x402Version: 1).
  • Scheme-agnostic: the inner payload of PaymentPayload and the extra of PaymentRequirements are passed through opaquely; the signer owns scheme knowledge ("exact" on EVM uses EIP-3009 / EIP-712).
  • No wallet, no chain RPC, no key material. Ever.

See AGENTS.md for tool selection guidance and landmines.

License

MIT