Algo amount handling
Algo amount handling is one of the core capabilities provided by AlgoKit Utils. It allows you to reliably and tersely specify amounts of microAlgo and Algo and safely convert between them.
Any AlgoKit Utils function that needs an Algo amount will take an AlgoAmount object, which ensures that there is never any confusion about what value is being passed around. Whenever an AlgoKit Utils function calls into an underlying algosdk function, or if you need to take an AlgoAmount and pass it into an underlying algosdk function (per the modularity principle) you can safely and explicitly convert to microAlgo or Algo.
To see some usage examples check out the automated tests. Alternatively, you see the reference documentation for AlgoAmount.
AlgoAmount
Section titled “AlgoAmount”The AlgoAmount class provides a safe wrapper around an underlying number amount of microAlgo where any value entering or existing the AlgoAmount class must be explicitly stated to be in microAlgo or Algo. This makes it much safer to handle Algo amounts rather than passing them around as raw number’s where it’s easy to make a (potentially costly!) mistake and not perform a conversion when one is needed (or perform one when it shouldn’t be!).
To import the AlgoAmount class you can access it via: