RootSoft / algorand-dart

Unofficial community SDK to interact with the Algorand network, for Dart & Flutter
MIT License
36 stars 16 forks source link

Transfer assets using double type amount instead of int type #3

Closed joankabello closed 3 years ago

joankabello commented 3 years ago

Hello there,

On the method transfer() which is used to transfer assets, i see that the amount is type of int instead of double. Can this be changed ? Since when you transfer assets, you would need to transfer a double type like 1.5 for example. But this is not doable since the type specified from the SDK is an int.

Thanks

RootSoft commented 3 years ago

Hi Joan

This issue is actually the same as #2 . Transactions require the (asset) amount to be uint64. Because your decimals field is > 0, you have to do some basic math or you can use the format functions:

final amount = Algo.format(amount,decimals);

or

(amount * (pow(10, decimals)))
joankabello commented 3 years ago

Oh okay, i wasn't aware that the format method was also for the assets transfer, i thought it was only for the Algos transfers.

My misunderstanding on this one. Thanks for the explanation!