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

ono-web

v1.1.0

Published

JavaScript API for ONO blockchain

Readme

ono-web

JavaScript API for the ONO blockchain. Create HD wallets, build and submit signed transactions, and subscribe to live events from a core node — from both Node.js and the browser.

Requires an ono-core node >= 1.2.5 (this version introduced the domain-separated transaction hash). On Node.js, version 18+ is needed (the library relies on the global fetch).

Install

npm install ono-web
const { wallet, transaction, ServerClient, BrowserClient } = require('ono-web');

Quick start

const { wallet, transaction } = require('ono-web');

// 1. Create a wallet (or restore one from an existing mnemonic)
const { mnemonic, seed } = await wallet.newWalletData();
const hdWallet = wallet.hdWallet(seed);
const keyPair = wallet.generateKeyPair(hdWallet, 0);

// 2. Build and sign a transaction
const tx = transaction.generateTransaction(
    recipientPublicKeyHex, // 'to' address (compressed public key, hex)
    1.5, // amount
    {
        publicKey: keyPair.publicKey.toString('hex'),
        privateKey: keyPair.privateKey.toString('hex'),
    },
);

// 3. Submit it to the core node
const result = await transaction.sendTransaction(tx);

// 4. Look it up later by hash
const confirmed = await transaction.getTransactionByHash(tx.hash);

Wallet

Keys are derived with BIP39/BIP32 at the path m/44'/2909'/0'/0/<index>. An address on ONO is the account's compressed public key in hex.

| Function | Description | | ----------------------------------------- | -------------------------------------------------------------------------------------- | | wallet.newWalletData() | Generates a fresh mnemonic; resolves to { mnemonic, seed } (seed as hex). | | wallet.walletDataFromMnemonic(mnemonic) | Restores { mnemonic, seed } from an existing BIP39 mnemonic. | | wallet.hdWallet(seed) | Builds an HD wallet (hdkey instance) from a hex seed. | | wallet.generateKeyPair(hdWallet, index) | Derives the key pair at account index index. Has publicKey / privateKey buffers. |

Keep the mnemonic (and seed) secret — either one fully controls the wallet's funds.

Transactions

const { transaction } = require('ono-web');

// Optional configuration — defaults shown:
transaction.setCoreHost(new URL('http://core.ono.gg'));
transaction.setNetwork('mainnet'); // or 'testnet'

| Function | Description | | ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | transaction.setCoreHost(url) | URL of the core node used by sendTransaction / getTransactionByHash. | | transaction.setNetwork(network) | 'mainnet' (default) or 'testnet'. Mixed into the transaction hash, so it must match the node's network — a hash made for the wrong network is rejected. | | transaction.calculateFee(amount) | Fee preview: 0.01% of the amount, capped at 0.01. | | transaction.generateTransaction(to, amount, keyPair) | Builds, hashes, and signs a transaction locally. keyPair is { publicKey, privateKey } as hex strings. Returns the complete transaction object. | | transaction.sendTransaction(tx) | POSTs the transaction to the node (/transaction/init) and resolves with the node's JSON response. | | transaction.getTransactionByHash(hash) | Fetches a transaction by hash (/transaction/by-hash/:hash), including its block reference once mined. |

A generated transaction looks like:

{
    from: '03...',      // sender public key (hex)
    to: '02...',        // recipient public key (hex)
    amount: 1.5,
    fee: 0.00015,
    timestamp: 1786019896,          // seconds
    hash: '7206734a...',            // sha256 over the domain-separated preimage
    signature: 'feee20f1...'        // canonical (low-S) secp256k1 ECDSA over the hash
}

Live events (WebSocket)

Two clients implement the same subscription protocol; pick the one for your environment:

  • ServerClient — Node.js, built on the ws package.
  • BrowserClient — browsers, built on the native WebSocket.

Both keep the connection alive automatically (a ping every 30 seconds).

const { ServerClient } = require('ono-web'); // or BrowserClient in the browser

const client = new ServerClient('http://core.ono.gg'); // http(s) is converted to ws(s)

client.subscribe(
    (message, client) => {
        switch (message.type) {
            case 'NEW_TRANSACTION': // message.data: a transaction entering the mempool
            case 'NEW_BLOCK': // message.data: a freshly forged block
            case 'STATUS': // message.data: { lastBlockId, lastBlockHash }, sent on connect and every 30s
                console.log(message.type, message.data);
                break;
        }
    },
    (error) => console.error('bad message', error),
);

// later
client.disconnect();

Messages arrive as { type, data }. The ones relevant to API consumers are NEW_TRANSACTION, NEW_BLOCK, and STATUS (core >= 1.2.5); the node may also send peer-to-peer housekeeping types (PONG, PEERS_REQUEST, ...) which can simply be ignored.

Compatibility notes

  • ono-web >= 1.1.0 requires ono-core >= 1.2.5. The transaction hash preimage changed in core 1.2.5 (domain-separated: transaction|<network>|amount=..|from=..|timestamp=..|to=..); older cores reject transactions built by this version and vice versa.
  • Signatures are canonical (low-S) ECDSA over secp256k1, as required by core >= 1.2.5.
  • When talking to a node running with TESTNET=true, call transaction.setNetwork('testnet') before generating transactions.

License

MIT