Skip to content
wordpress meta

title: 'Token Balance Decimals'
date: '2021-04-17T10:14:25-05:00'
status: publish
permalink: /token-balance-decimals
author: admin
excerpt: ''
type: post
id: 1732
category:
    - Crypto
    - Python
tag: []
post_format: []

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:

```bash $ 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:

```bash $ 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:

```python $ 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.

100119330456178750000010*-18 1001.1933045617875 ````