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

@permaweb/hyperbalance

v0.2.3

Published

Client helpers for funding AO-backed HyperBEAM local ledgers.

Readme

hyperbalance

hyperbalance is a small TypeScript library for clients that need to pay into AO-backed HyperBEAM local ledgers before making a request.

For the standard AO-paid HyperBEAM bundler flow, no new payment metadata device is required. The library uses the routes HyperBEAM already exposes:

/[email protected]/info/address
/[email protected]/info/ao-payment-deposit-address
/[email protected]/info/ao-payment-ledger
/[email protected]/quote?resource=arweave-bytes&amount={bytes}
/[email protected]/now/balance/{address}
/[email protected]/balance?target={address}
/[email protected]/ingest

Client tools can then:

  1. find the node AO deposit address,
  2. quote the intended request,
  3. check the payer's local ledger balance,
  4. calculate the shortfall,
  5. send AO to the advertised deposit address,
  6. import the verified AO deposit into the local ledger,
  7. re-check the spendable local balance.

Install

Install from npm:

npm install @permaweb/hyperbalance

Basic Usage

import {
  DEFAULT_AO_TOKEN_ID,
  HYPERBEAM_AO_BUNDLER_QUOTE_ACTION,
  HYPERBEAM_DEFAULT_LEDGER_ID,
  HyperbalanceClient,
  discoverHyperbeamAoBundlerProfile,
} from "@permaweb/hyperbalance"

const client = new HyperbalanceClient({
  nodeUrl: "https://hyperbeam.example.com",
})

const profile = await discoverHyperbeamAoBundlerProfile({
  nodeUrl: "https://hyperbeam.example.com",
})
const address = "payer-wallet-address"

const balance = await client.getBalance({
  profile,
  ledgerId: HYPERBEAM_DEFAULT_LEDGER_ID,
  address,
})

console.log(balance.value)

const quote = await client.quote({
  profile,
  action: HYPERBEAM_AO_BUNDLER_QUOTE_ACTION,
  params: { bytes: 1234 },
})

console.log(quote.amount)
console.log(quote.advisories)

Bundler Free Tier And Trundler

LapEE-style HyperBEAM bundlers can expose a free byte tier and use [email protected] to limit how often a signer or IP receives that free tier. discoverHyperbeamAoBundlerProfile keeps the amount-only quote route on /[email protected]/quote, adds exact-request preflight at /[email protected]/preflight, and annotates the pricing descriptor with:

  • subject: the quoted input is an arweave-bytes byte count supplied as {bytes};
  • settlement: the real upload is settled by P4 on /[email protected]/item and /[email protected]/tx, with insufficient balance surfaced as HTTP 402;
  • zeroQuote: a zero quote can be a conditional free-tier result backed by [email protected]; amount-only quote calls do not consume quota, while preflight consumes/reserves quota for the exact signed request.

Amount-only quotes are conservative on trundler-aware nodes. If the node cannot prove that the exact request owns the next free slot, it returns the paid fallback amount so clients can fund the upload safely.

For deterministic UX, call client.preflight after constructing the signed bundler upload request and before submitting it:

const preflight = await client.preflight({
  action: HYPERBEAM_AO_BUNDLER_QUOTE_ACTION,
  profile,
  params: { bytes: file.size },
  request: signedUploadRequest,
})

if (preflight.decision === "free") {
  // The node reserved free-tier eligibility for this exact signed request.
}

if (preflight.paymentRequired) {
  // Fund at least preflight.amount before uploading.
}

The bundler behavior is paid fallback, not hard block: when trundler quota is exhausted, preflight returns decision: "paid" with the amount required for AO settlement.

Funding

Funding needs a transfer adapter that can sign and submit AO token messages. AoTokenTransferAdapter provides the HyperBEAM-compatible tag construction; the caller supplies wallet-specific signing/submission.

await client.ensureCredit({
  profile,
  ledgerId: HYPERBEAM_DEFAULT_LEDGER_ID,
  tokenId: DEFAULT_AO_TOKEN_ID,
  recipient: "payer-wallet-address",
  minimumBalance: 1_000_000n,
  transferAdapter,
})

Signed Paid Requests

hyperbalance does not define a new paid-service wire standard. The reusable pattern is:

  • sign the service call as a normal HyperBEAM HTTP message, usually with [email protected];
  • let the node's P4/service overlay identify the signer and charge its local ledger;
  • use hyperbalance to discover the payment profile, check or fund the signer balance, send the signed request, and optionally read the post-call balance.

The current Permaweb request primitive for signed HyperBEAM calls is @permaweb/ao-core-libs:

import AOCore from "@permaweb/ao-core-libs"
import { readFile } from "node:fs/promises"
import {
  HyperbalanceClient,
  arweaveAddressFromJwk,
  createAoCoreRequestSender,
} from "@permaweb/hyperbalance"

const nodeUrl = "https://hyperbeam.example.com"
const wallet = JSON.parse(process.env.ARWEAVE_WALLET_JSON!)
const signerAddress = await arweaveAddressFromJwk(wallet)
const aoCore = AOCore.init({
  jwk: wallet,
  url: nodeUrl,
})

const client = new HyperbalanceClient({ nodeUrl })
const audio = await readFile("/tmp/audio.wav")

const result = await client.paidRequest({
  fields: {
    path: "/[email protected]/transcribe",
    method: "POST",
    data: audio,
  },
  minimumBalance: BigInt(audio.byteLength),
  send: createAoCoreRequestSender(aoCore),
  signerAddress,
})

console.log(result.response.status)
console.log(result.before.value, result.after?.value)

For quoted routes, pass quote instead of, or in addition to, an explicit minimumBalance. For post-priced metered routes such as media ingest, use the same work-unit estimate the node will meter, for example input byte length.

See examples/pay-rb-whisper.mjs for a live rb script that funds AO into rb.mystical.computer when needed. It runs in fund/import mode by default; pass --execute only when explicitly testing the JS signed-request transport against P4.

For a prefilled edit-and-run playground that does the full rb flow from one Node entrypoint, including the Ruby "first five words" transform, use a local mystical.computer checkout for the native HyperBEAM smoke signer:

npm run build
ARWEAVE_WALLET=/path/to/wallet.json node examples/rb-whisper-ruby-playground.mjs --verbose

All rb examples can be pointed at a local node without editing source:

HYPERBALANCE_NODE_URL=http://127.0.0.1:8734 \
HYPERBALANCE_GATEWAY_URL=http://127.0.0.1:9000 \
HYPERBALANCE_STATE_URL=http://127.0.0.1:9000 \
HYPERBALANCE_TRANSFER_MODE=mock \
node examples/rb-whisper-ruby-playground.mjs

HYPERBALANCE_TRANSFER_MODE=mock is for local compliance tests only. It still exercises the node's AO payment import route, but expects the configured state endpoint to serve matching mock AO schedule/result data.

Constants vs Inference

The caller should normally provide:

  • node URL,
  • signer or wallet,
  • intended recipient address if it cannot be inferred,
  • minimum balance or intended operation to quote.

The node provides:

The library should not hardcode:

  • a specific deployment URL,
  • a specific ledger process ID,
  • deposit address equals operator address,
  • upload byte price.

The library does assume AO for HyperBEAM bundler payments.