Getting the exact balance of any tokens

Hello, so I was messing around the getting tokens and after a while I got this to working:

as seen on screenshot, I managed to get the balance of certain address, but the catch is, I have no idea how much this guy has in tokens. I mean the exact number like for example: 245.3353… in this example I have 0.4486 but the balance is showing 4486…, how can I parse the balance or determine the exact balance.

1 Like

You would use

Note that not all tokens have the same amount of decimals though, you have to find out how many it has and convert it accordingly

Sorry for a late reply, thanks for the answer, I understand everything.


yeah the above screenshot shows the tokens has 18 decimals i hink. so if your suing web3 library then web3.utils.fromWei(balance.toString(), "ether") should suffice or if your using ethers, then ethers.utils.formatEther() will work