Token Balance Decimals
Balance Decimals
Noting my python code for reference. If familiar with crypto currency tokens you may find the token balance does not have decimals but rather store the decimal value separately.
For example this query shows the balance:
$ curl -s https://api.ethplorer.io/getAddressInfo/0xbcB79558e0d66475882A36FaF4124Ec45aA70dA3\?apiKey\=freekey | jq -r '.tokens[0].balance'
1001193304561787500000
If you look at the token detail you see the decimals recorded:
$ curl -s https://api.ethplorer.io/getAddressInfo/0xbcB79558e0d66475882A36FaF4124Ec45aA70dA3\?apiKey\=freekey | jq -r '.tokens[0].tokenInfo.decimals'
18
More on the decimals here:
The Technology Behind Ethereum Tokens
For my python3 code I used as follow:
$ python3
Python 3.8.6 (default, Jan 27 2021, 15:42:20)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1001193304561787500000*10**-18
1001.1933045617875