{"id":1732,"date":"2021-04-17T10:14:25","date_gmt":"2021-04-17T15:14:25","guid":{"rendered":"https:\/\/blog.iqonda.net\/?p=1732"},"modified":"2021-04-17T10:19:20","modified_gmt":"2021-04-17T15:19:20","slug":"token-balance-decimals","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/token-balance-decimals\/","title":{"rendered":"Token Balance Decimals"},"content":{"rendered":"

Balance Decimals<\/h1>\n

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.<\/p>\n

For example this query shows the balance:<\/p>\n

$ curl -s https:\/\/api.ethplorer.io\/getAddressInfo\/0xbcB79558e0d66475882A36FaF4124Ec45aA70dA3\\?apiKey\\=freekey | jq -r '.tokens[0].balance' \n1001193304561787500000<\/code><\/pre>\n

If you look at the token detail you see the decimals recorded:<\/p>\n

$ curl -s https:\/\/api.ethplorer.io\/getAddressInfo\/0xbcB79558e0d66475882A36FaF4124Ec45aA70dA3\\?apiKey\\=freekey | jq -r '.tokens[0].tokenInfo.decimals'\n18<\/code><\/pre>\n

More on the decimals here:
\nThe Technology Behind Ethereum Tokens<\/a><\/p>\n

For my python3 code I used as follow:<\/p>\n

$ python3                                                                                                                         \nPython 3.8.6 (default, Jan 27 2021, 15:42:20) \n[GCC 10.2.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> 1001193304561787500000*10**-18\n1001.1933045617875<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

Balance Decimals Noting my python code for reference. If familiar with crypto currency tokens you may find the token balance<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[128,13],"tags":[],"class_list":["post-1732","post","type-post","status-publish","format-standard","hentry","category-crypto","category-python"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=1732"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1732\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=1732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=1732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=1732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}