Is it the number of tokens i have? or just the balance which i need to somehow convert into number of tokens if it is then how can i convert the balance into number of tokens?
Thanks.
ethereumjssolidity
Is it the number of tokens i have? or just the balance which i need to somehow convert into number of tokens if it is then how can i convert the balance into number of tokens?
Thanks.
Best Answer
The amount of your real balance is the outcome of method
balanceOf
divided by10 ** decimals()
. Methoddecimals()
returns the number of decimals used to get its user representation.Example: If
balanceOf
returns that I have 9000000000000 tokens and the outcome of methoddecimals
is 9 then the "display" variant of my tokens would be9000000000000 / (10 ** 9)
which is 9000 tokens.If your contract does not have
decimals()
method then "display" variant of your balance is whatever methodbalanceOf
returns without any additional calculations.