Hedera
Ask or search…
K
Comment on page

Hbars

Constructor
Type
Description
new Hbar(<amount>)
Hbar
Initializes the Hbar object
new Hbar(<amount>)

Hbar from:

Construct hbars from different representations.
V1
Method
Type
Description
Hbar.from(<amount, unit>)
HbarUnit
Hbars from the provided denomination
Hbar.fromTinybar(<amount>)
long
Hbars converted from tinybars
Java
//100 hbars converted to tinybars
Hbar.from(100, HbarUnit.Tinybar);
//Hbars from tinybars
Hbar.fromTinybar(100);
//v1.3.2
JavaScript
//100 hbars converted to tinybars
Hbar.from(100, HbarUnit.Tinybar);
//Hbars from tinybars
Hbar.fromTinybar(100);
//v1.4.4

Hbar to:

Convert hbars to a different unit/format.
V1
Method
Type
Description
as(<unit>)
HbarUnit
Specify the unit of hbar to convert to. Use As for Go.
toString()
Long
Hbar value converted to tinybars
Java
//100 hbars converted to tinybars
new Hbar(100).as(HbarUnit.Tinybar);
//100 hbars converted to tinybars
new Hbar(100).toTinybars();
//v1.3.2
JavaScript
//100 hbars converted to tinybars
new Hbar(100).as(HbarUnit.Tinybar);
//100 hbars converted to tinybars
new Hbar(100).toTinybars();
//v1.4.4

Hbar constants:

Provided constant values of hbars.
V1
Method
Type
Description
Hbar.MAX
Hbar
A constant value of the maximum number of hbars (50_000_000_000 hbars)
Hbar.MIN
Hbar
A constant value of the minimum number of hbars (-50_000_000_000 hbars)
Hbar.ZERO
Hbar
A constant value of zero hbars
Java
//The maximum number of hbars
Hbar hbarMax = Hbar.MAX;
//The minimum number of hbars
Hbar hbarMin = Hbar.MIN;
//Zero hbars
Hbar hbarZero = Hbar.ZERO;
//v1.3.2
JavaScript
//The maximum number of hbars
const hbarMax = Hbar.MAX;
//The minimum number of hbars
const hbarMin = Hbar.MIN;
//Zero hbars
const hbarZero = Hbar.ZERO;
//v1.4.4

Hbar units

Modify the hbar representation to one of the hbar denominations.
V1
Function
Description
HbarUnit.Tinybar
The atomic (smallest) unit of hbar, used natively by the Hedera network
HbarUnit.Microbar
Equivalent to 100 tinybar or 1⁄1,000,000 hbar.
HbarUnit.Millibar
Equivalent to 100,000 tinybar or 1⁄1,000 hbar
HbarUnit.Hbar
The base unit of hbar, equivalent to 100 million tinybar.
HbarUnit.Kilobar
Equivalent to 1 thousand hbar or 100 billion tinybar.HbarUnit.Megabar
HbarUnit.Megabar
Equivalent to 1 million hbar or 100 trillion tinybar.
HbarUnit.Gigabar
Equivalent to 1 billion hbar or 100 quadrillion tinybar.
Java
Hbar.from(100, HbarUnit.Tinybar);
//v1.3.2
JavaScript
Hbar.from(100, HbarUnit.Tinybar);
//v1.4.4