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

@altananetwork/x402-server

v0.2.0

Published

Seller-side x402/B402 payments: 402 challenges, X-PAYMENT verification (EOA + ERC-1271), and on-chain settlement for agents charging per request.

Readme

@altananetwork/x402-server

Seller-side x402/B402 payments for agents that charge per request.

Put guard() in front of any HTTP route and it becomes a paid capability: unpaid requests get a 402 challenge; requests carrying a valid X-PAYMENT header are settled on-chain, immediately and passed through.

Payable out of the box by:

  • BNB Agent Studio agents (bag x402 trust <your-url>bag x402 buy) — they sign EIP-3009 TransferWithAuthorization on $U (United Stables).
  • Altana SDK agents (fetchWithX402 / the MCP x402_request tool) — smart-account session keys signing the B402 permit2-exact rail (ERC-1271).
  • Anything else speaking the B402 v2 wire (CAIP-2 networks, scheme:"exact", extra.assetTransferMethod).

Usage

import { privateKeyToAccount } from "viem/accounts";
import { bsc } from "viem/chains";
import { createX402Merchant, U_TOKEN, USDT_BSC } from "@altananetwork/x402-server";

const merchant = createX402Merchant({
  chainId: 56,
  payTo: "0xYourAltanaSmartAccount",          // where earnings land
  price: 200_000_000_000_000_000n,            // 0.2 per call (18 dec)
  minPrice: 50_000_000_000_000_000n,          // clamp floor
  maxPrice: 2_000_000_000_000_000_000n,       // clamp ceiling
  rails: [
    { rail: "eip3009", token: U_TOKEN[56] },  // Studio buyers
    { rail: "permit2-exact", token: USDT_BSC, spender: facilitator.address }, // Altana/B402 buyers
  ],
  resource: "https://api.example.com/audit",
  facilitator: privateKeyToAccount(process.env.FACILITATOR_KEY),  // settler EOA (gas only)
  rpcUrl: "https://bsc-dataseed.binance.org",
  chain: bsc,
});

Bun.serve({
  port: 8080,
  async fetch(req) {
    const { response, receipt } = await merchant.guard(req);
    if (response) return response;             // 402 (challenge or rejection)
    return Response.json({ data: await doTheWork(), tx: receipt.txHash });
  },
});

How settlement works

| Rail | Buyer signs | Settled via | Verified by | | --- | --- | --- | --- | | eip3009 | TransferWithAuthorization ($U) | token.transferWithAuthorization(bytes) | the token contract | | permit2-exact | PermitWitnessTransferFrom (any Permit2-approved token) | Permit2.permitWitnessTransferFrom | Permit2 |

The facilitator account only broadcasts and pays gas — funds move directly from the payer to payTo. The recipient is bound into the buyer's signature (EIP-3009 to / the permit2 Witness), so a compromised facilitator key cannot redirect earnings.

Off-chain checks run first (token, amount within [minPrice, maxPrice], recipient, expiry, signature). Checker-restricted smart accounts (Altana session keys answer isValidSignature only to their approved checker) defer the signature check to the settling contract — an invalid signature reverts the settlement, and the request is refused. Replay is impossible: EIP-3009 nonces and the Permit2 nonce bitmap burn on-chain.

Verified end-to-end

tests/e2e/fork-x402-server.ts runs both buyer families against a real BNB-mainnet fork (genuine $U, USDT and Permit2 bytecode): Studio-envelope eip3009 settlement, Altana session-key permit2-witness settlement, and replay refusal. Run it with bun run fork:x402-server from tests/e2e.