In this track: Digital value and units
beginner · 3 MIN READ

Display units versus raw units

A friendly number and a machine integer can describe the same amount.

LET’S PICTURE IT

A calendar can display “one hour” while a timer stores 3600 seconds. Different representations serve different jobs.

SEE IT FOR YOURSELF
The same native ether amount shown as ETH, Gwei and WeiETH1× 1 billionGWEI1000000000× 1 billionWEI1000000000000000000

1 ETH = 1000000000 Gwei = 1000000000000000000 Wei.

Same value · different units · native ether only

Name both representations

For ETH, 1.25 is a possible display amount and 1250000000000000000 is its raw Wei amount. The display needs a unit label. The raw amount needs a scale definition before it can be turned back into a human-readable value.

Read the function’s contract

An argument named amount does not prove which scale is intended. For an ERC-20 transfer it usually means raw token units. Other contracts may define shares, fixed-point ratios or application-specific quantities. Read the interface and implementation documentation.

Avoid applying the scale twice

If a wallet has already converted 1 ETH into Wei, multiplying the raw result by 10¹⁸ again creates a huge unintended number. Similarly, dividing an already formatted amount a second time makes it far too small.

Write labels in your own code

Names such as amountWei and amountEthText help distinguish representations. Try the ABI encoder with the raw integer 100, then compare it with the Wei converter. Encoding does not give a number an economic meaning by itself.

TURN UNDERSTANDING INTO PRACTICEOpen the Wei / Gwei / ETH →
QUICK CHECK · NO PRESSURE

Should you multiply a value already expressed in Wei by 10¹⁸ to send ETH?

Your progress stays in this browser.
Keep exploring the original referenceethereum.org ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.