trezor / blockbook

:blue_book: Trezor address/account balance backend
https://trezor.io
GNU Affero General Public License v3.0
653 stars 647 forks source link

Issue with Decimal Value for Ethereum Tokens #1074

Open alirezazeynali75 opened 5 months ago

alirezazeynali75 commented 5 months ago

Hi everyone,

Description:

When interacting with the Blockbook API to query transactions involving Ethereum tokens with a decimal value of 0, such as Sensorium, inconsistencies arise in the reported decimal value. Despite tokens having a specified decimal value of 0, the API response consistently returns a decimal value of 18. This discrepancy creates confusion and inaccuracies when processing token values and can potentially lead to incorrect calculations or interpretations of token transactions.

Steps to Reproduce:

  1. Call the Blockbook API endpoint for a transaction involving a token with a decimal value of 0, for example, Sensorium.
  2. Analyze the API response to observe the reported decimal value.

Expected Behavior:

The Blockbook API response should accurately reflect the decimal value specified for the token in the transaction. Tokens with a decimal value of 0 should consistently return a decimal value of 0 in API responses.

Actual Behavior:

The Blockbook API returns a decimal value of 18 for tokens with a decimal value of 0, irrespective of the token's actual decimal value. This behavior contradicts the expected behavior and introduces ambiguity and inconsistency in token value representation.

Example API Response:

{
  "tokenTransfers": [
    {
      "type": "ERC20",
      "from": "0x0D0707963952f2fBA59dD06f2b425ace40b492Fe",
      "to": "0x7Daf50dBeBd312E29fA8A6C9507856F9Ab4547d7",
      "contract": "0xC19B6A4Ac7C7Cc24459F08984Bbd09664af17bD1",
      "name": "Sensorium",
      "symbol": "SENSO",
      "decimals": 18,
      "value": "4915"
    }
  ]
}

Additional Info

  1. Token with decimal value of 0: Sensorium
  2. Block number: 19752710
  3. Endpoint: /api/v2/block/19752710
  4. TxHash: 0x77b6ee2e04041d00d039f1fa597708b1b937cf69f9c920b844ee8d2d8484df6a
tomasklim commented 5 months ago

https://github.com/trezor/blockbook/issues/1026