Trying to get metamask wallet balance

Try to fetch balance from metamask wallet using web3 getbalance function but getting this huge number how to convert it to normal form.
Please anyone can help me out from this issue :warning:


window.web3 = await Moralis.Web3.enable();
web3.utils.toWei("10", "ether")
=> "10000000000000000000"
web3.utils.toWei("0.01", "ether")
=> "10000000000000000"
web3.utils.fromWei("10000000000000000", 'ether')
=> "0.01"

1 Like

Thanks a lot solved my problemπŸ™‚

hey man, sorry i don’t know exactly how to implement this, do i use this on the buy button ?

Yup You can use this