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

@stacknet/x402payg

v0.6.0

Published

Client SDK for StackNet x402 pay-as-you-go

Readme

@stacknet/x402payg

Pay-as-you-go client SDK. A PAYG key is a pg_ API key bound to your wallet by your wallet's signature and funded by an on-chain payment. StackNet routes reserve each call's price against that funding before running it and return HTTP 402 when it can't cover the call; the client raises that as a typed PaymentRequired with required / remaining, and topUpFor tops the key up so you can retry. Buy, use, top up, list and revoke keys.

npm install @stacknet/x402payg
import { Keypair } from '@solana/web3.js';
import { X402PaygClient, walletFromKeypair } from '@stacknet/x402payg';

const payg = new X402PaygClient({ stacknetBaseUrl: 'https://stacknet.magma-rpc.com' });
const wallet = walletFromKeypair(Keypair.fromSecretKey(secretKey));

const { apiKey, quote } = await payg.createKey(wallet, {
  stackId: 'stk_jmqog66ha0mugmro',
  mint: 'SOL',
  amount: 10_000_000n,
});
  • Purchase quotes. Before paying, the client requests a short-lived server quote bound to the wallet, stack, mint and amount, and commits its id on chain as the metadata nonce. The key is credited the quoted amount. purchaseQuotes: 'auto' | 'required' | 'off'.
  • Signed preflight. With a wallet signer the config preflight carries a signed challenge (x402-payg-v1:config:<wallet>:<ts>), so wallet-specific invite and spend data is returned only to that wallet.
  • Signing domains. Since 0.5.0 every wallet signature uses the x402-payg-v1: domains (key, list, revoke, allow-invite, reserve, config); app-invite reservations sign stacknet-payg-v2:reserve-app:. StackNet 3.16.164 and later also accept the original stacknet-payg-v1: form, so keys from earlier SDKs keep working and a key re-derived with 0.5.0 reaches the same balance. Use 0.5.0 only against StackNet 3.16.164 or later.
  • Protocol limits. X402PAYG_LIMITS is StackNet's x402payg-limits.v1 contract: proof size tiers 286 / 1,111 / 2,222 bytes with 128 bytes of headroom (the SDK picks the smallest tier the metadata fits), proof expiry at most 518,400 s (6 days), signatures fresh for 300 s, quotes valid 600 s, minimum funding 1 cent, 1 token = 1 µUSD, stack ids and nonces at most 128 bytes. The preflight compares the server's published limits with this contract and refuses to pay on a difference (protocol_mismatch).
  • 402 Payment Required. callWithKey(apiKey, path, init) throws PaymentRequired (code: 'payment_required', required, remaining, keyId, and shortfall = required − remaining) when a route answers 402 PAYG_TOP_UP_REQUIRED; nothing ran. topUpFor(wallet, params, key, error) tops the key up (or switches/buys) and returns the key to retry with; paymentRequiredFrom(response) parses a 402 you fetched yourself.
  • Pay from Ethereum or Robinhood Chain (@stacknet/x402payg/evm, StackNet 3.16.173 or later). new X402PaygEvmClient({ stacknetBaseUrl }).createKeyFromEvm(wallet, { network: 'eip155:1', amount: 18_000_000n, stackId }) pays USDC (Ethereum) or USDG (Robinhood Chain) from an EIP-1193 wallet through a bridge order that delivers exactly amount USDC to the StackNet vault on Solana, credited 1:1 (minimum $18; the payer also pays the bridge's input spread and a fixed 0.001 ETH fee). The SDK decodes the bridge's order before the wallet signs (exact amount, vault receiver and authority, payer as source authority, no external call or affiliate fee) and refuses anything else; each step is checkpointed and resume(wallet, operationId) continues without paying twice.
  • Errors. Failures are X402PaygClientError with a stable code; messages never include response bodies, credentials or URLs.

Keep API keys, wallet secrets and invite credentials private. Mainnet only; payments are real.

Full guide: the "PAYG integration guide" page of the Geoff docs.

Releasing

This directory is the only publish source. The x402payg release workflow builds and publishes from a tagged commit on main (x402payg-v<version>) after approval of the protected npm-publish environment. dist/ is committed because apps/geoff imports the package through the workspace; CI fails unless it is exactly build:publish of this source. prepublishOnly re-runs the tests, typecheck and publish build and verifies the packed files contain no source or source maps.