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

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new AlgoAmount(amount): AlgoAmount

Create a new AlgoAmount instance.

Parameters

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.

Returns

AlgoAmount

A new instance of AlgoAmount representing the specified amount.

Example

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

Defined in

src/types/amount.ts:37

Properties

amountInMicroAlgo

Private amountInMicroAlgo: bigint

Defined in

src/types/amount.ts:5

Accessors

algo

get algo(): number

Return the amount as a number in Algo

Returns

number

Defined in

src/types/amount.ts:23


algos

get algos(): number

Return the amount as a number in Algo

Returns

number

Defined in

src/types/amount.ts:18


microAlgo

get microAlgo(): bigint

Return the amount as a number in µAlgo

Returns

bigint

Defined in

src/types/amount.ts:13


microAlgos

get microAlgos(): bigint

Return the amount as a number in µAlgo

Returns

bigint

Defined in

src/types/amount.ts:8

Methods

toString

toString(): string

Returns

string

Defined in

src/types/amount.ts:50


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

src/types/amount.ts:58


Algo

Algo(amount): AlgoAmount

Create a AlgoAmount object representing the given number of Algo

Parameters

NameType
amountnumber | bigint

Returns

AlgoAmount

Defined in

src/types/amount.ts:68


Algos

Algos(amount): AlgoAmount

Create a AlgoAmount object representing the given number of Algo

Parameters

NameType
amountnumber | bigint

Returns

AlgoAmount

Defined in

src/types/amount.ts:63


MicroAlgo

MicroAlgo(amount): AlgoAmount

Create a AlgoAmount object representing the given number of µAlgo

Parameters

NameType
amountnumber | bigint

Returns

AlgoAmount

Defined in

src/types/amount.ts:78


MicroAlgos

MicroAlgos(amount): AlgoAmount

Create a AlgoAmount object representing the given number of µAlgo

Parameters

NameType
amountnumber | bigint

Returns

AlgoAmount

Defined in

src/types/amount.ts:73