Why Ether Has 18 Decimals: Calculate Wei, Gwei and Gas Correctly
18 decimals make amounts precise, not transactions cheap. A complete EIP-1559 calculation, fee caps versus actual consumption and common token mistakes.
The wallet shows the amount in ETH. The fee quote comes in Gwei. The raw transaction stores one long integer in Wei. Same currency: 1 ETH = 10¹⁸ Wei. That is why 0.000000000000000001 ETH is the integer 1.
Eighteen places are a protocol convention. The name Wei traces back to the cryptographer Wei Dai. I know of no documented reason for this exact width. The terms are in the glossary entry on Wei, Gwei and gas. Finer units do not change what you pay. The fee is gas used, times the price the block is charging.
Three units cover everyday use
| Unit | Value in Wei | Purpose |
|---|---|---|
| Wei | 1 | Smallest ETH unit, storage and exact arithmetic |
| Gwei | 10⁹ | Common gas-price display |
| ETH | 10¹⁸ | Human-readable amounts |
1 ETH = 1 billion Gwei. Gas measures execution work. The price is quoted in Gwei per unit of gas. The limit and the fee are different quantities. In the example below, 21,000 is the gas and 22 is the price in Gwei per gas. The fee from those two numbers is 462,000 Gwei.
Calculate a complete EIP-1559 transaction
Work an ordinary execution transaction on Ethereum mainnet, with no separate blob fee. The figures are assumptions for the arithmetic, not live network prices.
| Item | Assumption |
|---|---|
| Gas actually used | 21,000 |
| Base fee in the including block | 20 Gwei |
| Maximum priority fee | 2 Gwei |
Maximum fee per gas (maxFeePerGas) | 30 Gwei |
Under EIP-1559 (glossary), the tip is the smaller of the priority fee and the room left under the cap: min(2, 30 − 20) = 2 Gwei. The effective gas price is 20 + 2 = 22 Gwei.
Fee: 21,000 × 22 Gwei = 462,000 Gwei = 0.000462 ETH. The base fee burns 21,000 × 20 = 420,000 Gwei. The priority fee is the remaining 42,000 Gwei. On a real raw transaction, read maxFeePerGas, maxPriorityFeePerGas and the gas limit in the Transaction Decoder.
30 Gwei is the cap inside the signed transaction. The block charges the effective price, 22 Gwei in this example. If the base fee rises to 29 Gwei and the cap stays put, the tip falls to 1 Gwei. If the base fee sits above 30 Gwei, a transaction with this fee cap cannot be included.
Gas limit and actual consumption differ
21,000 gas is the cost of a plain ETH transfer: no extra data, no recipient code executed. A token transfer or a swap runs contract logic and can cost more. A higher gas limit does not make that same call confirm sooner.
For an ordinary transaction the ETH balance has to cover the amount and the maximum execution fee. Sending 0.01 ETH with a 21,000 gas limit and a 30 Gwei cap requires 0.01 + 0.00063 = 0.01063 ETH. In the example above, the amount plus the execution fee actually charged is 0.010462 ETH.
Gas the call does not burn is not billed as consumption in this calculation. Work a contract has already performed still costs a fee if the call then fails. Layer-2 networks can add data-publication costs. There, the mainnet shortcut is not necessarily the whole bill.
Tokens have their own decimal places
The 18 decimals belong to ETH. For an ERC-20, decimals is metadata of that token, and the standard leaves it optional. On an illustrative token with 6 decimals, 1,000,000 smallest units are exactly one token. Apply the ETH factor of 10¹⁸ without reading decimals, and the UI shows the wrong amount.
A normal self-funded ERC-20 transfer on Ethereum still needs ETH for gas. The token you are sending does not settle that fee. Sponsored transactions and other networks are separate cases.
In software, parse amounts as integers
JavaScript’s Number cannot hold large Wei amounts as exact integers. Use BigInt, and read the decimal amount as a string before you scale it. BigInt(0.1 * 10**18) is not a safe conversion: the multiply runs in floating point, and BigInt only wraps the result.
Decide what too many decimal places mean before you accept the input. Reject them, or round by a rule you defined on purpose. Check the fee from above in the ETH Unit Converter. 462,000 Gwei should come back as 0.000462 ETH.
Sources:
- Ethereum: Gas and fees — gas consumption and fee components.
- EIP-1559 — fee caps and effective priority fees.
- ERC-20 — optional token decimal metadata.
Continue reading
- Pending transactions and nonces
- Compare UTXO and account fees
- Geld 2.0 — money and its technical representation.