ono-web

If you want integrate ONO to your project, you can use some ready funcitonality to do that.

🌐 ono-web — ONO Blockchain Web Client SDK

The ono-web package is a JavaScript SDK designed to help developers easily interact with the ONO blockchain. It allows you to create wallets, generate transactions, and connect to the ONO P2P network using WebSockets — all from your Node.js applications.


📦 Installation

To install the ono-web package, run the following command in your project:

npm i ono-web --save

This will add ono-web to your project's dependencies.


🚀 What is ono-web?

ono-web is an official ONO blockchain SDK that allows you to:

  • 🔑 Generate wallets using mnemonic phrases (BIP-39).

  • 🔐 Generate and sign transactions.

  • 💸 Send transactions to the ONO network.

  • 🌐 Connect to the ONO core node via WebSocket and listen for real-time events like new blocks and transactions.


✨ Features

  • Wallet Generation Easily generate new wallets or recover existing wallets using mnemonic phrases.

  • HD Wallet & Key Derivation Supports hierarchical deterministic (HD) wallets to derive multiple addresses from a single seed.

  • Transaction Creation and Signing Securely create and sign transactions directly on the client side.

  • Fee Calculation Automatically calculate transaction fees according to ONO network rules.

  • WebSocket P2P Support Connect to the ONO core network and subscribe to real-time blockchain events (e.g., new blocks, transactions).

  • Configurable Core Host Connect to different ONO core nodes (mainnet, testnet, or private node).


📚 Modules Overview

Module
Description

wallet

Manage wallet creation, seed generation, and key pair derivation.

transaction

Create, sign, and send transactions with fee calculation.

socket

Connect to ONO core node and subscribe to real-time blockchain events.


🛠 Usage Example

const ono = require('ono-web');

// Generate new wallet
const walletData = await ono.wallet.newWalletData();
console.log(walletData.mnemonic);
console.log(walletData.seed);

// Generate transaction
const hdWallet = ono.wallet.hdWallet(walletData.seed);
const keyPair = ono.wallet.generateKeyPair(hdWallet, 0);

const tx = ono.transaction.generateTransaction('receiverPublicKey', 100, {
  publicKey: keyPair.publicKey.toString('hex'),
  privateKey: keyPair.privateKey.toString('hex')
});

await ono.transaction.sendTransaction(tx);
console.log('Transaction sent:', tx);

// Connect to WebSocket
const socketClient = new ono.socket();
socketClient.subscribe(
  (message) => console.log('Received message:', message),
  (error) => console.error('Socket error:', error)
);

📝 Notes

  • Requires Node.js v22+.

  • Make sure your environment allows WebSocket and HTTP(S) connections to the ONO core node.

  • Always keep your mnemonic and private keys safe and secure.

Last updated