Hi there, I’m trying to using Moralis’s web3 instance in cloud function for dealing with big numbers and having some computations. Here is the below sample code I’m using:
const chain = "0x1";
// web3 instance using Moralis
const web3 = Moralis.web3ByChain(chain);
// basic calculation using web3's utils -> not gives proper output
const result = web3.utils.toBN(5).mul(web3.utils.toBN(5)).div(web3.utils.toBN(4))
return result.toString()
So, I’m getting output as 6
, however, it should be 6.25
. As I’m actually working with token balances, total supply etc., and doing computations on top of them, then I’m getting inaccurate outputs.
Could you please assist me with the possible solution for it?
Thanks.