In this track: Connect everything together
Build an exact unit converter
Preserve every digit through ETH, Gwei and Wei conversions.
An exact ruler must not bend when the number becomes large.
1 ETH = 1000000000 Gwei = 1000000000000000000 Wei.
Define accepted inputs
Wei values are whole integers; ETH can have up to eighteen fractional places and Gwei up to nine. Decide and explain how invalid precision is rejected.
Use lossless arithmetic
Parse decimal strings into integer raw units. Avoid routing a large amount through JavaScript Number before converting it to BigInt.
Format deterministically
Show decimal strings without scientific notation or hidden rounding. Keep the asset quantity separate from any price or fiat calculation.
Verify boundary fixtures
Test zero, one Wei, one ETH and a very large exact integer. A valid parse-format round trip should retain the intended amount.
Your acceptance target
1 ETH = 1000000000000000000 Wei
1 Gwei = 1000000000 Wei
1 Wei = 0.000000000000000001 ETHUse only local examples and public sample addresses. State the assumptions and limits alongside the result.
Which representation avoids initial floating-point loss?
Loss before BigInt conversion cannot be recovered.
Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.