Wallet

πŸ“– Wallet Module

The wallet module in the ono-web package provides utilities to generate and manage ONO wallets using BIP39 mnemonics and HD (Hierarchical Deterministic) key derivation.


πŸ“¦ Importing

To use the wallet module, import it as follows:

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

πŸš€ Functions

1. wallet.newWalletData()

Generates a new wallet with a mnemonic phrase and a seed.

βœ… Returns

  • Promise<WalletData> β€” an object containing:

    • mnemonic: The generated mnemonic phrase (BIP39).

    • seed: The seed derived from the mnemonic (hex string).

πŸ“ Example


2. wallet.walletDataFromMnemonic(mnemonic)

Generates a wallet seed from an existing mnemonic phrase.

πŸ“₯ Parameters

Name
Type
Description

mnemonic

string

A valid BIP39 mnemonic phrase

βœ… Returns

  • Promise<WalletData> β€” an object containing:

    • mnemonic: The input mnemonic phrase.

    • seed: The derived seed (hex string).

πŸ“ Example


3. wallet.hdWallet(seed)

Creates an HD wallet (Hierarchical Deterministic Wallet) from a seed.

πŸ“₯ Parameters

Name
Type
Description

seed

string

Seed in hexadecimal format

βœ… Returns

  • HDKey β€” an HD wallet object that can be used to derive key pairs.

πŸ“ Example


4. wallet.generateKeyPair(hdWallet, index)

Generates a key pair (private/public key) from an HD wallet at a specific index using the ONO HD path m/44'/2909'/0'/0/index.

πŸ“₯ Parameters

Name
Type
Description

hdWallet

HDKey

An HD wallet object

index

number

The index to derive the key at

βœ… Returns

  • HDKey β€” a key pair (contains publicKey and privateKey).

πŸ“ Example


πŸ“š Types

WalletData

  • mnemonic: BIP39 mnemonic phrase.

  • seed: Hexadecimal string derived from mnemonic.


βš™οΈ HD Path

The ONO blockchain uses the following HD derivation path:

  • 2909 β€” Coin type index reserved for ONO.

  • index β€” Allows multiple accounts/addresses under the same seed.


πŸ’‘ Usage Example (Full Flow)


🚨 Notes

  • Always back up your mnemonic phrase securely. It is the only way to recover your wallet.

  • Never share your private key; anyone with access to it can control your funds.

  • For forging ONO coins, remember to burn at least 100 ONO coins from the wallet address you plan to use.

Last updated