tondiamonds / ton-nft-deployer

https://tondiamonds.github.io/ton-nft-deployer/
117 stars 33 forks source link

> In the current implementation of the topUpBalance function, the balance is calculated incorrectly because it's being multiplied by a floating-point value and not converted to the smallest TON unit. This leads to an "Invalid number" error when sending transfers. #13

Open hajizade1992 opened 4 weeks ago

hajizade1992 commented 4 weeks ago
          > In the current implementation of the topUpBalance function, the balance is calculated incorrectly because it's being multiplied by a floating-point value and not converted to the smallest TON unit. This leads to an "Invalid number" error when sending transfers.

Error Description:

The error occurs in the following line when trying to send the transaction:

Error: Invalid number 

This happens because the amount is not being properly converted into nanoTONs, which is required for accurate transfer in TON.

Suggested Fix:

The issue can be resolved by using the toNano() function to convert the floating-point value into nanoTONs (smallest unit of TON). This will ensure the amount is in the correct format and prevent the "Invalid number" error.

Here's an example of how the amount calculation should be corrected:

const amount = toNano(nftAmount * 0.026); // Correctly converts amount to nanoTONs
Screenshot 2024-09-06 at 12 13 05 PM

Originally posted by @Amirbakhtiaro in https://github.com/tondiamonds/ton-nft-deployer/issues/10#issuecomment-2399379251