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

@krewe/x402-client

v0.1.0

Published

x402 payment client for the krewe decentralized inference network on Base. Pay per inference call in USDC via EIP-3009 — no API keys, no signup.

Readme

@krewe/x402-client

Pay-per-call client for the krewe decentralized inference network on Base. Settles each call in USDC via EIP-3009 transferWithAuthorization — no API keys, no signup, no rate-limit dashboards. If your wallet has USDC on Base, you can call the network.

The network runs 3-of-3 fan-out with 2-of-3 byte-equal consensus on every job — your inference call is independently verified before you get a response. See krewe-AI/krewe for the full protocol.

Install

pnpm add @krewe/x402-client viem
# or: npm i @krewe/x402-client viem

Quickstart

import { createX402Client } from "@krewe/x402-client";
import { privateKeyToAccount } from "viem/accounts";

const client = createX402Client({
  signer: privateKeyToAccount(process.env.AGENT_PRIVATE_KEY as `0x${string}`),
});

const result = await client.predict({
  kind: "text.structure",
  payload: {
    text: "Email [email protected] about the meeting on 2026-06-12.",
  },
});

console.log(result.output);
// → { emails: ["[email protected]"], urls: [], dates: ["2026-06-12"], numbers: [] }
console.log(`Paid: ${result.paymentTxHash} (replicas=${result.replicas})`);

Supported job kinds

| kind | Price (USDC) | Description | |-------------------|--------------|------------------------------------------------------| | text.structure | $0.005 | Extract emails, URLs, dates, numbers, phones | | text.embed | $0.010 | Sentence embeddings (Xenova/all-MiniLM-L6-v2) | | web.scrape | $0.020 | Fetch + clean a small URL payload | | text.complete | $0.050 | Quantized SLM completion (Xenova/Qwen2.5-0.5B) |

How it works

  1. client.predict(req) POSTs /v2/predict without payment → orchestrator returns HTTP 402 with an x402 challenge (recipient, USDC amount, nonce, 5-minute deadline).
  2. SDK signs the challenge as an EIP-3009 TransferWithAuthorization typed-data message using your wallet.
  3. SDK re-POSTs with X-PAYMENT: base64(json({challenge, from, v, r, s})).
  4. Orchestrator verifies the signature off-chain, submits transferWithAuthorization on-chain, runs the inference job across 3 miners, returns the consensus result with the on-chain paymentTxHash.

The orchestrator pays the gas (~$0.001 on Base) and recovers it from the payment itself.

Advanced: two-step flow

If you want to show a user the price before signing:

const challenge = await client.getChallenge({ kind: "text.complete", payload: { prompt: "…" } });
console.log(challenge.description); // "$0.050000 for text.complete"

// (display to user, get confirmation, …)

const payment = await client.signChallenge(challenge);
const result  = await client.submitWithPayment({ kind: "text.complete", payload: {...} }, payment);

Spending cap

By default the SDK rejects any quoted price > $0.10 per call. Override with maxPricePerCallUsdc:

const client = createX402Client({
  signer,
  maxPricePerCallUsdc: 1_000_000n, // $1.00 per call
});

Browser usage

The SDK uses fetch and Buffer only — works in Node ≥ 18, Bun, Deno, Cloudflare Workers, Vercel Edge, and browsers (with a wallet-injected signer like wagmi's useWalletClient).

import { createWalletClient, custom } from "viem";
import { base } from "viem/chains";

const wallet = createWalletClient({ chain: base, transport: custom(window.ethereum) });
const [address] = await wallet.getAddresses();

const client = createX402Client({
  signer: {
    address,
    signTypedData: (params) => wallet.signTypedData({ account: address, ...params }),
  },
});

License

MIT. See LICENSE.