Skip to content

AlgoAmount

@algorandfoundation/algokit-utils / types/amount / AlgoAmount

types/amount.AlgoAmount

Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbers

new AlgoAmount(amount): AlgoAmount

Create a new AlgoAmount instance.

NameTypeDescription
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.

AlgoAmount

A new instance of AlgoAmount representing the specified amount.

Example

const amount = new AlgoAmount({ algo: 5 });

src/types/amount.ts:37

Private amountInMicroAlgo: bigint

src/types/amount.ts:5

get algo(): number

Return the amount as a number in Algo

number

src/types/amount.ts:23


get algos(): number

Return the amount as a number in Algo

number

src/types/amount.ts:18


get microAlgo(): bigint

Return the amount as a number in µAlgo

bigint

src/types/amount.ts:13


get microAlgos(): bigint

Return the amount as a number in µAlgo

bigint

src/types/amount.ts:8

toString(): string

string

src/types/amount.ts:50


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

number

src/types/amount.ts:58


Algo(amount): AlgoAmount

Create a AlgoAmount object representing the given number of Algo

NameType
amountnumber | bigint

AlgoAmount

src/types/amount.ts:68


Algos(amount): AlgoAmount

Create a AlgoAmount object representing the given number of Algo

NameType
amountnumber | bigint

AlgoAmount

src/types/amount.ts:63


MicroAlgo(amount): AlgoAmount

Create a AlgoAmount object representing the given number of µAlgo

NameType
amountnumber | bigint

AlgoAmount

src/types/amount.ts:78


MicroAlgos(amount): AlgoAmount

Create a AlgoAmount object representing the given number of µAlgo

NameType
amountnumber | bigint

AlgoAmount

src/types/amount.ts:73