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

@mariano-aguero/anthropic-x402-tools

v0.1.0

Published

Give a Claude agent the ability to pay for x402 APIs with ERC-20 tokens: a paying fetch tool and a balance tool for the Anthropic SDK tool runner

Readme

@mariano-aguero/anthropic-x402-tools

npm License: MIT

Give a Claude agent the ability to pay for x402 APIs with stablecoin.

Two ready-made tools for the Anthropic SDK's tool runner:

  • fetch_url: fetches from an allowlisted API. When the server answers with a 402 payment challenge, the tool checks the wallet can afford it, pays via the official x402 client, and returns the data plus the settlement tx hash. The model never touches keys or signatures.
  • check_balance: reads the wallet's token and native balances so the agent can reason about affordability.

Safety rails built in: the allowlist compares parsed origins (immune to prefix and userinfo tricks), unreadable challenges are refused rather than treated as free, and every settled payment is recorded so your app can print an audit trail.

Install

pnpm add @mariano-aguero/anthropic-x402-tools @anthropic-ai/sdk viem zod

@anthropic-ai/sdk, viem and zod are peer dependencies. Node 20 or newer.

Usage

import Anthropic from "@anthropic-ai/sdk";
import { createX402Tools } from "@mariano-aguero/anthropic-x402-tools";
import { privateKeyToAccount } from "viem/accounts";
import { arbitrumSepolia } from "viem/chains";

const { tools, payments } = createX402Tools({
  account: privateKeyToAccount(process.env.AGENT_PRIVATE_KEY as `0x${string}`),
  chain: arbitrumSepolia,
  token: { address: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d" }, // USDC
  apiBase: "https://api.example.com",
});

const client = new Anthropic();
const message = await client.beta.messages.toolRunner({
  model: "claude-opus-5",
  max_tokens: 16000,
  tools,
  messages: [{ role: "user", content: "Buy me one premium insight and quote it." }],
});

for (const p of payments) {
  console.log(`paid ${p.amount} (tx ${p.txHash})`);
}

The agent wallet only needs the payment token. With the EIP-3009 exact scheme the receiving side submits the settlement transaction, so the agent never spends gas.

Options

| Option | Required | Description | | --- | --- | --- | | account | yes | viem LocalAccount (e.g. from privateKeyToAccount) that signs payment authorizations. | | chain | yes | Any viem Chain; the CAIP-2 network id derives from chain.id. | | token | yes | Payment token address; decimals defaults to 6. | | apiBase | yes | Origin allowlist. The tools refuse any URL on a different origin. | | rpcUrl | no | RPC override for balance reads. | | fetchImpl | no | Fetch implementation, injectable for tests. | | fetchToolDescription | no | Custom tool description if your API needs different guidance. |

Lower-level access

createX402ToolsFromDeps accepts explicit plainFetch / payingFetch / wallet implementations. It is what the package's own tests use, and the hook for custom transports or mocking.

See it working

The arbitrum-agent-payments starter kit runs these tools end to end against an x402 seller on Arbitrum Sepolia, one command, real testnet settlement.

License

MIT