Hedera
Search…
Hbars
Constructor
Type
Description
new Hbar(<amount>)
Hbar
Initializes the Hbar object
1
new Hbar(<amount>)
Copied!

Hbar from:

Construct hbars from different representations.
V2
V1
Method
Type
Description
Hbar.from(<hbars>)
long / BigDecimal
Returns an Hbar whose value is equal to the specified value
Hbar.from(<hbars, unit>)
long / BigDecimal , HbarUnit
Returns an Hbar representing the value in the given units
Hbar.fromString(<text>)
CharSequence
Converts the provided string into an amount of hbars
Hbar.fromString(<text, unit>)
CharSequence, HbarUnit
Converts the provided string into an amount of hbars
Hbar.fromTinybars(<tinybars>)
long
Returns an Hbar converted from the specified number of tinybars
Java
1
//100 hbars
2
new Hbar(100);
3
4
//100 hbars from hbar value
5
Hbar.from(100);
6
7
//100 tinybars from hbars convert to unit
8
Hbar.from(100, HbarUnit.TINYBAR);
9
10
// 100 hbars converted from string value
11
Hbar.fromString("100");
12
13
//100 tinybars from string value
14
Hbar.fromString("100", HbarUnit.TINYBAR);
15
16
//v2.0.0
Copied!
JavaScript
1
// 100 hbars
2
new Hbar(100);
3
4
//100 hbars
5
Hbar.from(100);
6
7
//100 tinybars
8
Hbar.from(100, HbarUnit.TINYBAR);
9
10
// 100 hbars converted from string value
11
Hbar.fromString("100");
12
13
//100 tinybars from string value
14
Hbar.fromString("100", HbarUnit.TINYBAR);
Copied!
Go
1
//100 hbars
2
hedera.NewHbar(100)
3
4
//100 tinybars
5
hedera.HbarFrom(100, hedera.HbarUnits.Tinybar)
6
7
//v2.0.0
Copied!
Method
Type
Description
Hbar.from(<amount, unit>)
HbarUnit
Hbars from the provided denomination
Hbar.fromTinybar(<amount>)
long
Hbars converted from tinybars
Java
1
//100 hbars converted to tinybars
2
Hbar.from(100, HbarUnit.Tinybar);
3
4
//Hbars from tinybars
5
Hbar.fromTinybar(100);
6
7
//v1.3.2
Copied!
JavaScript
1
//100 hbars converted to tinybars
2
Hbar.from(100, HbarUnit.Tinybar);
3
4
//Hbars from tinybars
5
Hbar.fromTinybar(100);
6
7
//v1.4.4
Copied!

Hbar to:

Convert hbars to a different unit/format.
V2
V1
Method
Type
Description
to(<unit>)
HbarUnit
Specify the unit of hbar to convert to. Use As for Go.
toString(<unit>)
HbarUnit
String value of the hbar unit to convert to. Use String() for Go.
toTinybars()
Long
Hbar value converted to tinybars
Java
1
//100 hbars converted to tinybars
2
new Hbar(100).to(HbarUnit.TINYBAR);
3
4
//100 hbars converted to tinybars
5
new Hbar(100).toString(HbarUnit.TINYBAR);
6
7
//100 hbars converted to tinybars
8
new Hbar(100).toTinybars();
9
10
//v2.0.0
Copied!
JavaScript
1
//100 hbars converted to tinybars
2
new Hbar(100).to(HbarUnit.TINYBAR);
3
4
//100 hbars converted to tinybars
5
new Hbar(100).toString(HbarUnit.TINYBAR);
6
7
//100 hbars converted to tinybars
8
new Hbar(100).toTinybars();
Copied!
Go
1
//100 hbars converted to tinybars
2
hedera.NewHbar(100).As(hedera.HbarUnits.Tinybar)
3
4
//100 hbars to string format
5
hedera.NewHbar(100).String()
6
7
//100 hbars converted to tinybars
8
hedera.NewHbar(100).AsTinybar()
9
//v2.0.0
Copied!
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
1
//100 hbars converted to tinybars
2
new Hbar(100).as(HbarUnit.Tinybar);
3
4
//100 hbars converted to tinybars
5
new Hbar(100).toTinybars();
6
7
//v1.3.2
Copied!
JavaScript
1
//100 hbars converted to tinybars
2
new Hbar(100).as(HbarUnit.Tinybar);
3
4
//100 hbars converted to tinybars
5
new Hbar(100).toTinybars();
6
7
//v1.4.4
Copied!

Hbar constants:

Provided constant values of hbars.
V2
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
1
//The maximum number of hbars
2
Hbar hbarMax = Hbar.MAX;
3
4
//The minimum number of hbars
5
Hbar hbarMin = Hbar.MIN;
6
7
//A constant value of zero hbars
8
Hbar hbarZero = Hbar.ZERO;
9
10
//v2.0.0
Copied!
JavaScript
1
//The maximum number of hbars
2
const hbarMax = Hbar.MAX;
3
4
//The minimum number of hbars
5
const hbarMin = Hbar.MIN;
6
7
//A constant value of zero hbars
8
const hbarZero = Hbar.ZERO;
Copied!
Go
1
//The maximum number of hbars
2
hbarMax := hedera.MaxHbar
3
4
//The minimum number of hbars
5
hbarMin := hedera.MinHbar
6
7
//A constant value of zero hbars
8
hbarZero := hedera.ZeroHbar
9
10
//v2.0.0
Copied!
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
1
//The maximum number of hbars
2
Hbar hbarMax = Hbar.MAX;
3
4
//The minimum number of hbars
5
Hbar hbarMin = Hbar.MIN;
6
7
//Zero hbars
8
Hbar hbarZero = Hbar.ZERO;
9
10
//v1.3.2
Copied!
JavaScript
1
//The maximum number of hbars
2
const hbarMax = Hbar.MAX;
3
4
//The minimum number of hbars
5
const hbarMin = Hbar.MIN;
6
7
//Zero hbars
8
const hbarZero = Hbar.ZERO;
9
10
//v1.4.4
Copied!

Hbar units

Modify the hbar representation to one of the hbar denominations.
V2
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
1
//100 tinybars
2
Hbar.from(100, HbarUnit.TINYBAR);
3
4
//v2.0.0
Copied!
JavaScript
1
//100 tinybars
2
Hbar.from(100, HbarUnit.TINYBAR);
3
4
//v2.0.0
Copied!
Go
1
//100 tinybars
2
hedera.HbarFrom(100, hedera.HbarUnits.Tinybar)
3
4
//v2.0.0
Copied!
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
1
Hbar.from(100, HbarUnit.Tinybar);
2
3
//v1.3.2
Copied!
JavaScript
1
Hbar.from(100, HbarUnit.Tinybar);
2
3
//v1.4.4
Copied!
Last modified 6d ago