0

i am working on a Web3 project where i have a balance of tokens which i want to burn. The problem that the amount of balance is in this format

0.29806008728157019

So when i pass this amount to the burn method it loss its precision and it becomes

0.2980600872815702

I've tried many things like converting it to big number before passing it as a parameter like this web3.utils.toBN( Math.trunc(amount * 1000000000000000000) ); i tried to convert it to a string then use parseFloat like this:

 const value = web3.utils.toBN(
Math.trunc(parseFloat(amount) * 1000000000000000000)
);

But none of these worked. Any help please ?

Ghost
  • 318
  • 2
  • 8
  • Please add the code that generates the wrong number. Standard js method `parseFloat` works fine with your number – kikon Oct 31 '22 at 13:44

0 Answers0