In this track: Digital value and units
Display units versus raw units
A friendly number and a machine integer can describe the same amount.
A calendar can display “one hour” while a timer stores 3600 seconds. Different representations serve different jobs.
1 ETH = 1000000000 Gwei = 1000000000000000000 Wei.
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.
Should you multiply a value already expressed in Wei by 10¹⁸ to send ETH?
Convert from displayed ETH into Wei once, then keep that integer through the transaction pipeline.
Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.