Etherscan

Etherscan scales displayed ERC-20 balances using the token's decimal count

Updated on

Etherscan displays ERC-20 token quantities by scaling raw balances with the decimal count of the token contract. Contract responses and application programming interface (API) fields may show integers in the token's smallest unit. The readable amount equals that integer divided by ten raised to the decimal count. This explains why equal raw balances can represent different quantities across contracts. Matching amounts also requires the same token and balance snapshot; decimal conversion alone cannot reconcile records that measure different things.

Matching an address holding to a contract balance

A token holding on an address page and a direct contract balance can describe the same quantity using different units. The holdings view presents an amount for reading, while the contract reports an integer. The difference concerns representation when both figures refer to the same account, token contract, and blockchain state. A longer integer does not establish that the account owns more tokens.

Reading the same holding in contract units

The account balance

Where the Read Contract interface is available, balanceOf reports the token balance for the supplied account address. A conventional ERC-20 contract returns this amount in its smallest unit. The returned integer carries no embedded decimal point. It also does not identify a market price or explain when an address received its holding.

The decimal metadata

When implemented, the separate decimals function supplies the scale for interpreting that integer. Its value belongs to the token contract, rather than the account that holds the tokens.

Agreement between the formatted holding and the contract response requires compatible units and a matching snapshot. An account can change its balance between reads. Interface rounding can also suppress digits without changing the underlying amount. A mismatch that survives correct scaling therefore needs an explanation beyond the decimal count, such as a different observation time or non-standard contract behavior.

The decimal count sets the unit scale

ERC-20 decimal metadata specifies the exponent for a power of ten that connects smallest units with readable token quantities. Let R denote the raw integer balance and d the token's decimal count. The readable token amount equals R divided by 10 raised to the power d. This relationship changes the unit of expression without moving tokens. The reverse conversion multiplies a readable quantity by the same factor, provided that the quantity corresponds to an exact integer amount.

What does the decimal count actually change?

The decimal count changes the displayed unit scale, while conventional ERC-20 balance and transfer operations continue to use integer amounts. It determines the smallest fraction of a whole displayed token that a raw unit represents. This distinction lets interfaces show fractional quantities without requiring a fractional return value from balanceOf. The contract's amount remains an integer throughout the calculation.

A decimal count does not describe the number of holders, the market price, or a supply ceiling. Display software can show fewer fractional places than the token supports. That formatting choice does not redefine the contract's unit. Conversely, extra trailing zeros in a presentation add no precision to the original balance and do not create additional transferable units.

Four views expose token amounts in different forms

The address interface, contract reader, and API expose related quantities with different representations and access requirements. Their fields need an explicit unit meaning before software combines them. A balance describes a holding at a particular state; a transfer amount describes a recorded movement. The same scaling relationship applies to conventional ERC-20 quantities, while each view retains its own purpose.

Four views expose token amounts in different forms
View Amount format Quantity described Required inputs or access
Address token holdings Formatted token quantity An address's holding The address and matching token contract
Read Contract: balanceOf Integer in smallest units The contract-reported account balance An available read interface and account address
tokenbalance API String containing smallest units The current token balance An API key, chain ID, token contract, and account address
tokentx API Raw value with tokenDecimal metadata A recorded token transfer amount An API key, chain ID, and address or contract filter
Comparable quantities need matching token identities, compatible units, and an appropriate balance snapshot or transfer record.

The API's field names matter independently of the website's formatting. The current-balance response identifies its result as an amount in the token's smallest unit. The transfer response includes an amount alongside decimal metadata. An application that treats either raw field as whole tokens changes the quantity's meaning before any price calculation begins.

Transfer records measure movements through the token contract

A recorded ERC-20 transfer and a current balance answer different questions, even when both concern the same address and token contract. The transfer amount describes a movement in the record. The balance describes the account's holding at the queried state. A correctly formatted transfer amount therefore does not establish the account's later balance or every change that affected it.

The amount inside a transfer record

The tokentx API response associates value with tokenDecimal, the token contract, and the transfer addresses. The decimal field supplies an exponent for formatting the raw amount. It does not measure a fee or specify an exchange rate. The sender and recipient identify the movement that the amount describes; neither address turns that field into a current holding.

Standard ERC-20 transfer events contain an integer amount. A decoder interprets the event fields, and a formatter applies the relevant token scale. These operations change how the record appears to a reader. They do not alter the recorded amount. A token quantity also differs from the native-currency value of the enclosing Ethereum transaction, which measures a different asset.

Contract behavior can affect balance comparisons

Reflection mechanisms can change holdings outside ordinary transfers involving the holder. Non-standard contracts can also produce misleading events. Correct decimal arithmetic cannot make an incomplete transfer history equal a reliable current balance.

Are equal raw balances equal token amounts?

Equal positive raw balances represent equal numerical token quantities only when their contracts use the same decimal count. A larger decimal count assigns a smaller displayed amount to the same positive integer. Comparing raw integers across different token contracts therefore discards information that the conversion needs.

Matching decimal counts still do not make different tokens interchangeable or equally valuable. Contract identity establishes which asset the quantity describes. Names and symbols can repeat across contracts, so a comparison needs the relevant contract on the relevant chain. Arithmetic can compare properly labeled quantities; it cannot establish that two labels represent the same economic asset.

Large balances need exact arithmetic before formatting

Token APIs can return long integer strings that ordinary floating-point arithmetic cannot always preserve exactly. JavaScript's Number type cannot represent every integer beyond its safe integer range. Parsing a raw balance into that type can lose low-order digits before the decimal conversion begins. Dividing the altered number later cannot restore digits that the earlier conversion discarded.

Integer arithmetic or an exact decimal representation preserves the original amount through formatting. A formatter can position the decimal point using the token scale without approximating the raw integer. Rounding belongs at the display boundary, with the unrounded amount retained for calculations. Summing already rounded display values can introduce another difference, because omitted fractions can accumulate across records.

Supply figures follow the token's own unit convention

The tokensupply API returns total supply in the token's smallest unit, so a readable supply needs the same scale as its balances. A large raw supply alone reveals little about the number of whole tokens. The totalSupply function describes supply in existence; the decimal count does not establish a maximum issuance limit or the portion that circulates in markets.

For a balance and a nonzero total supply from the same contract and state, their common decimal factor cancels in a ratio. Dividing the raw balance by raw supply gives the same proportion as dividing their exactly scaled amounts. Mixing a raw numerator with a formatted denominator breaks that relationship. Comparing supplies across different contracts also requires each contract's separate scale.

The same unit convention applies to an allowance, the amount that a spender may use under a token approval. A readable allowance describes authorized spending, whereas a readable balance describes holdings.

Etherscan: Supply figures follow the token's own unit convention - diagram

Open full-size image

Historical balances require a consistent block context

The historical-balance API ties an account's token holding to a specified block, separating a past quantity from a current balance query. This endpoint requires the Standard API plan or a higher plan and returns the historical amount in smallest units. Its block parameter identifies the state that the quantity describes. A later balance can differ because the account or contract changed after that block.

A historical conversion also needs decimal metadata that applies to the relevant contract state. A constant decimal function gives a stable scale, while custom or upgradeable implementations require attention to their actual behavior. A current metadata value alone does not establish every historical value. Comparisons across dates retain meaning when both the balance context and its applicable unit convention remain clear.

Missing metadata leaves the readable quantity uncertain

The ERC-20 specification makes decimals optional, so token-compatible software cannot assume that every contract supplies a usable decimal response. A raw balance can remain available even when this metadata is absent. The missing field does not establish a decimal count. A formatter that substitutes an assumed value introduces a unit convention that the returned balance itself never specified.

Explorer metadata, a contract response, and an application's cached token settings can differ. An unresolved scale disagreement leaves the readable quantity uncertain without proving that tokens disappeared. Reflection and other non-standard implementations can cause additional display discrepancies. These conditions need separate explanations: correcting a decimal exponent addresses unit conversion, while correcting stale or misleading balance data addresses the underlying quantity.

A readable token quantity still needs a separate price

The decimal scale establishes a token quantity, while market valuation requires a separate price for the matching asset. Etherscan's holdings interface distinguishes quantity, price, and value for this reason. A missing price does not make a contract balance zero. A very large displayed quantity likewise does not establish liquidity, a redeemable claim, or a corresponding amount of another asset.

A decimal mistake can multiply or divide the token quantity used in a portfolio calculation. It can therefore distort the value even when the price is correct. Correct scaling resolves that unit error. The remaining valuation still depends on the applicable price and what the token represents. Retaining the exact amount lets a portfolio calculation use the token's full quantity, even when its readable display rounds away smaller fractional units.

Things people ask about Etherscan

Can an ERC-20 token on Etherscan have zero decimals?

An ERC-20 token can declare zero decimals, making its smallest unit equal to a whole displayed token. The conversion factor then equals one, so the raw integer and readable quantity have the same numerical value. This does not make a zero-decimal response equivalent to missing metadata. A contract that supplies no decimal value leaves the scale unspecified; a contract that returns zero supplies a definite scale.

Does reading a token's decimals require a wallet signature?

Reading a token's decimal count through a standard read-only contract call does not require a wallet signature. The call queries the contract without creating a blockchain transaction or changing its state. A balance query also uses the account address as input without authorizing spending from that account. Access to an API can require a key, which is separate from signing an on-chain transaction.

What happens if software applies token decimal scaling twice?

Applying decimal scaling twice divides an already formatted quantity by an additional factor of ten raised to the token's decimal count. The underlying contract balance remains unchanged. This mistake occurs when a later component assumes that a readable amount still contains smallest units. Distinguishing raw amount fields from formatted strings prevents this unit mismatch. When the decimal count is zero, the factor equals one.

Do token decimals determine Ethereum gas charges?

A token's decimal count does not set Ethereum's gas price or the fee per unit of gas. Transaction fees depend on gas usage and the applicable fee parameters, with payment in the network's native currency. The token amount uses its own contract's unit scale. Changing how an interface displays that amount does not change an existing transaction's gas usage or recorded fee.

Why does an ERC-721 token ID not use ERC-20 decimal scaling?

An ERC-721 token ID identifies a particular non-fungible token rather than measuring a fungible token quantity. Dividing that identifier by a decimal factor would change the identifier's meaning. ERC-721 balanceOf counts the tokens that an address owns; it does not return a fractional amount of an individual token. A shared function name therefore does not authorize applying ERC-20 amount formatting to every token standard.

Is a comma-separated displayed balance a valid token contract amount?

An ERC-20 amount parameter represents an encoded unsigned integer in smallest units, so display commas do not belong in that parameter. Thousands separators and a displayed decimal point help people read quantities. Software needs the original integer or an exact conversion before encoding a contract call. A fractional displayed quantity must correspond to a whole number of smallest units; presentation punctuation cannot supply that conversion.

When can a positive token balance display as zero?

An interface can display zero when its chosen precision rounds or truncates away a positive quantity's nonzero fractional digits. The formatting does not remove any tokens. With a known decimal scale, every positive raw integer still represents a positive token quantity. The original balance therefore distinguishes an empty holding from an amount that the interface cannot show at its selected precision.