# ono-web

## 🌐 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:

```bash
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

```javascript
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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://berinis-organization.gitbook.io/ono/integration/ono-web.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
