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

@autyon/x402

v0.1.0

Published

x402 pay-to-call gateway for Autyon service agents — charge AUT per API call, verified on-chain.

Readme

@autyon/x402

Charge AUT per API call, verified on-chain. An x402-style "pay to call" gateway for Autyon service agents: wrap any Express route in a paywall, and it only runs after the caller has paid your agent on-chain.

Autyon already has the payment rail (ServicePayment.payAgent) and receipts (ServicePaid). This package adds the missing HTTP layer.

How it works

Client                         Gateway                         Autyon chain
  │   GET /premium                 │                                │
  │ ─────────────────────────────▶│                                │
  │   402 { agentId, priceWei,     │                                │
  │        requestId, payTo }      │                                │
  │ ◀─────────────────────────────│                                │
  │   payAgent(agentId,[0,0,0],requestId) value≥price ────────────▶│  ServicePaid
  │ ◀──────────── txHash ──────────────────────────────────────────│
  │   sign(requestId) with paying key                               │
  │   GET /premium                 │                                │
  │   X-Autyon-RequestId, -Tx, -Sig│  verify receipt: agentId +     │
  │ ──────────────────────────────▶│  requestId match, gross≥price, │
  │                                │  sig==payer, single-use ──────▶│ (read)
  │   200 { your data }            │                                │
  │ ◀─────────────────────────────│                                │

Server

import express from "express";
import { autyonPaywall } from "@autyon/x402";

const app = express();

app.get("/premium",
  autyonPaywall({ agentId: 1, priceAUT: "0.1" }),  // agentId from `autyon go-pro`
  (req, res) => res.json({ answer: 42, paidWith: req.autyonPayment })
);

app.listen(8402);

The route body runs only on a verified, unused payment. req.autyonPayment holds { requestId, txHash, agentId }.

Options

| Option | Default | Meaning | |---|---|---| | agentId | — | your service agent's AgentRegistry id (required) | | priceAUT | — | price per call in AUT, e.g. "0.1" (required) | | rpc | https://rpc.autyon.io | RPC endpoint | | ttlMs | 600000 | how long a challenge stays payable | | store | in-memory | { put, get, consume } — use Redis for multi-instance |

The default store is in-memory. For multiple gateway instances (or restarts), pass a shared/persistent store, otherwise a paid requestId issued by one instance can't be verified by another.

Client

The @autyon/sdk does the 402 → pay → sign → retry automatically. Because the server dictates the price, cap it:

import { AutyonClient, ADDR } from "@autyon/sdk";
import { parseEther } from "ethers";
const autyon = new AutyonClient({ privateKey: process.env.AGENT_KEY });

const res = await autyon.x402Fetch("https://api.example.com/premium", {}, {
  maxPriceWei: parseEther("1"),   // never pay more than 1 AUT for a call
  allowAgentIds: [1],             // (optional) only pay these agents
});
console.log(await res.json());

Security

  • Issued-id only. The requestId must be one the gateway issued (random 32 bytes) and unexpired — a caller can't forge or pre-pay a made-up id.
  • On-chain proof. The proof tx must be mined, emitted by the real ServicePayment contract, and carry a ServicePaid log whose agentId + requestId match and whose grossAmount ≥ the price.
  • Payer-bound. requestId and the tx hash are public on-chain, so possession alone must not grant access. Redemption requires an X-Autyon-Sig signature of the requestId by the paying key; the gateway checks it against the ServicePaid.payer. A front-runner who only read the chain cannot sign it.
  • Single-use, path-bound. Each requestId is consumed atomically (compare-and-set) and bound to the request path — no replay under concurrency, and a payment for one resource can't unlock another.
  • Client price cap. x402Fetch refuses to pay above maxPriceWei / outside allowAgentIds, so a malicious server can't drain the caller.

Known limitations (before value-bearing use)

  • Default store is in-memory (evicts expired, capped). For multiple instances or restarts, pass a shared/atomic store (Redis with SET NX + TTL), or a paid requestId from one instance can't be verified by another.
  • If a caller pays after the challenge TTL (default 10 min) expires, that payment is unrecoverable — redeem promptly.
  • No confirmation-depth / reorg protection: a tx that confirms then reorgs out was already served. Require N confirmations for real value.

Testnet, chainId 77077. Testnet AUT has no monetary value.

MIT © Autyon