AlgoAmount
@algorandfoundation/algokit-utils / types/amount / AlgoAmount
types/amount.AlgoAmount
Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbers
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new AlgoAmount(amount
): AlgoAmount
Create a new AlgoAmount
instance.
Parameters
Name | Type | Description |
---|---|---|
amount | { algos : number | bigint } | { algo : number | bigint } | { microAlgos : number | bigint } | { microAlgo : number | bigint } | An object specifying the amount in Algo or µALGO. Use the key ‘algo’ for Algo amounts and ‘microAlgo’ for µALGO. |
Returns
A new instance of AlgoAmount
representing the specified amount.
Example
const amount = new AlgoAmount({ algo: 5 });
Defined in
Properties
amountInMicroAlgo
• Private
amountInMicroAlgo: bigint
Defined in
Accessors
algo
• get
algo(): number
Return the amount as a number in Algo
Returns
number
Defined in
algos
• get
algos(): number
Return the amount as a number in Algo
Returns
number
Defined in
microAlgo
• get
microAlgo(): bigint
Return the amount as a number in µAlgo
Returns
bigint
Defined in
microAlgos
• get
microAlgos(): bigint
Return the amount as a number in µAlgo
Returns
bigint
Defined in
Methods
toString
▸ toString(): string
Returns
string
Defined in
valueOf
▸ valueOf(): number
valueOf allows you to use AlgoAmount
in comparison operations such as <
and >=
etc.,
but it’s not recommended to use this to convert to a number, it’s much safer to explicitly call
the algos or microAlgos properties
Returns
number
Defined in
Algo
▸ Algo(amount
): AlgoAmount
Create a AlgoAmount
object representing the given number of Algo
Parameters
Name | Type |
---|---|
amount | number | bigint |
Returns
Defined in
Algos
▸ Algos(amount
): AlgoAmount
Create a AlgoAmount
object representing the given number of Algo
Parameters
Name | Type |
---|---|
amount | number | bigint |
Returns
Defined in
MicroAlgo
▸ MicroAlgo(amount
): AlgoAmount
Create a AlgoAmount
object representing the given number of µAlgo
Parameters
Name | Type |
---|---|
amount | number | bigint |
Returns
Defined in
MicroAlgos
▸ MicroAlgos(amount
): AlgoAmount
Create a AlgoAmount
object representing the given number of µAlgo
Parameters
Name | Type |
---|---|
amount | number | bigint |