Transaction
📖 Transaction Module
The transaction
module in the ono-web package provides utilities to create, sign, calculate fees, and send transactions on the ONO blockchain network.
📦 Importing
To use the transaction module, import it as follows:
🚀 Functions
1. transaction.setCoreHost(url)
transaction.setCoreHost(url)
Sets a custom ONO core node host URL for sending transactions. By default, the host is http://core.ono.gg
.
📥 Parameters
url
URL
URL object of the core host
📝 Example
2. transaction.calculateFee(amount)
transaction.calculateFee(amount)
Calculates the transaction fee based on a percentage of the transaction amount.
Fee formula:
0.0001%
of the transaction amount, but never more than 0.01 ONO.
📥 Parameters
amount
number
Amount to be sent in the transaction
✅ Returns
number
— Calculated transaction fee (ONO).
📝 Example
3. transaction.generateTransaction(to, amount, keyPair)
transaction.generateTransaction(to, amount, keyPair)
Generates and signs a new transaction object.
📥 Parameters
to
string
Recipient's public key (address)
amount
number
Amount of ONO coins to send
keyPair
object
Object with publicKey
and privateKey
of the sender
✅ Returns
Transaction
— A signed transaction object ready to send.
🔑 Transaction Object Fields
hash
string
Hash of the transaction
from
string
Sender's public key
to
string
Recipient's public key
amount
number
Amount of ONO coins being sent
fee
number
Transaction fee
timestamp
number
Unix timestamp of transaction creation
signature
string
Cryptographic signature of the hash
📝 Example
4. transaction.sendTransaction(transactionData)
transaction.sendTransaction(transactionData)
Sends a signed transaction to the ONO core network for processing.
📥 Parameters
transactionData
Transaction
A signed transaction object
✅ Returns
Promise<Object>
— Response from the core server, typically includes success status or error.
📝 Example
⚙️ Constants
Transaction Fee Percent
0.0001% of transaction amount
Maximum fee cap: 0.01 ONO
📚 Types
Transaction
Transaction
💡 Usage Example (Full Flow)
🚨 Notes
Ensure the sender's address has enough ONO balance to cover both the amount and fee.
Transactions are signed locally, ensuring security of private keys.
You can change the ONO core node address via
setCoreHost()
if you want to use your own node.
Last updated