Balances can be added or subtracted from each other, and a balance can be multiplied by or divided by a number. This takes advantage of the underlying bignumber.js library for handling large numbers accurately without running into floating point errors.
Balances can be converted between HNT, DC and USD. Some of these conversions require the consultation of a price oracle. A price oracle is the current value of HNT in USD as understood by the Helium blockchain for the purpose of burning HNT to DC. The current price oracle value can be retrived using @helium/http
@helium/currency
Utilities for handling the different currency types on the Helium blockchain. For more details see the following resources:
Installation
Usage
@helium/currency
has two main concepts:Balance
CurrencyType
A
Balance
represents an amount of one of the supportedCurrencyType
s. The following currency types are supported:CurrencyType.networkToken
)CurrencyType.dataCredit
)CurrencyType.security
)CurrencyType.usd
)Basic Usage
Balances are constructed with their integer value representation, since this is how the API returns them.
Arithmetic Operations
Balances can be added or subtracted from each other, and a balance can be multiplied by or divided by a number. This takes advantage of the underlying
bignumber.js
library for handling large numbers accurately without running into floating point errors.Conversions
Balances can be converted between HNT, DC and USD. Some of these conversions require the consultation of a price oracle. A price oracle is the current value of HNT in USD as understood by the Helium blockchain for the purpose of burning HNT to DC. The current price oracle value can be retrived using
@helium/http