In this track: Digital value and units
What are token decimals?
A token’s display scale tells you where to place the decimal point.
A game token could have a hundred small pieces per token or a million. The label does not tell you how many pieces the contract counts.
1 ETH = 1000000000 Gwei = 1000000000000000000 Wei.
The contract counts raw units
For an ERC-20 token, an interface often uses decimals metadata to display the integer returned by balanceOf. If decimals is six, a raw balance of 1234567 is displayed as 1.234567 tokens.
Compare two scales
At eighteen decimals, that same raw number would be 0.000000000001234567 tokens. The raw integer has not changed. The display rule changed. This is why a decoder cannot infer a human token amount from uint256 alone.
Metadata is not universal proof
The ERC-20 decimals method is optional metadata in the specification. Implementations and interfaces need a policy for missing or unusual metadata. A declared decimal count also does not establish a token’s price, trustworthiness or supply policy.
Keep ETH conversion separate
Our Wei converter applies the native ETH scale only. For token amounts, obtain the correct network, token contract and decimal information before formatting. The ABI encoder deliberately shows raw amounts without inventing this missing context.
A raw balance of 1234567 with six decimals displays as…
Divide the raw amount by 10⁶. The token’s symbol and market price are separate metadata.
Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.