Glossary
Wei
Ethereum's atomic unit
By Buğra SözeriPublished Updated
Wei is the smallest, indivisible unit of Ether. 1 ETH = 10¹⁸ Wei = 1,000,000,000,000,000,000 Wei. Named after Wei Dai, the cryptographer whose 1998 b-money proposal is one of the conceptual ancestors of Bitcoin and the broader smart-contract ecosystem.
Smart contracts on Ethereum perform all balance arithmetic in integer Wei amounts. There’s no floating point on-chain — every value field, gas calculation, and balance is an unsigned 256-bit integer Wei value. ETH and Gwei are purely human-facing labels; the EVM only knows Wei.
In JavaScript this matters because Number.MAX_SAFE_INTEGERis roughly 9 × 10¹⁵. A 9 ETH balance is roughly 9 × 10¹⁸ Wei — three orders of magnitude past Number’s precision floor. Production wallet libraries use BigInt for Wei amounts. Our Wei / Gwei / ETH converter uses BigInt throughout so conversions round-trip without precision loss.
Why 18 decimals specifically?Ethereum’s designers wanted a fractional resolution large enough that even at extreme gas prices the cost of a transaction is comfortably expressible without scientific notation, and large enough that the smallest practical fee (currently a few thousand Wei) is still a whole number. 18 decimals also sits comfortably below the 2²⁵⁶ ceiling — a value field on the Ethereum chain can represent up to ~1.158 × 10⁷⁷ Wei, more Ether than the universe could plausibly contain. ERC-20 tokens inherit the same 18-decimal convention by default for consistency with the base layer, though tokens are free to choose their own decimals (USDC uses 6, WBTC uses 8).
Practical Wei amounts you’ll see in a wallet: a typical mainnet transaction at 30 Gwei gas price with a 21 000-gas simple transfer costs 30 × 10⁹ × 21 000 = 6.3 × 10¹⁴ Wei = 0.00063 ETH. A complex smart-contract interaction (Uniswap swap, NFT mint) might burn 200 000+ gas — order of 10¹⁶ Wei. Reading a raw transaction in Etherscan shows the value field as a decimal Wei string for exactness; the UI layer above renders it as ETH with a unit toggle. Related: Gwei, BigInt. Reference: Ethereum Yellow Paper.
Worked example
You want to send 0.025 ETH from a script. Convert to Wei: 0.025 × 10¹⁸ = 25,000,000,000,000,000 Wei — a 17-digit integer. Naive JavaScript: 0.025 * 1e18 evaluates to 25000000000000000 but storing it as a regular Number drops precision on intermediate arithmetic (try 0.1 * 1e18 + 0.2 * 1e18 — you get 299999999999999970, off by 30 Wei). The correct pattern uses BigInt: ethers.parseEther("0.025") returns 25000000000000000n (a BigInt) which arithmetic preserves exactly. Now send: at 25 Gwei gas price for a 21,000-gas transfer, fee = 25n * 10n**9n * 21000n = 525000000000000n Wei = 0.000525 ETH. Total leaving the wallet: 25000000000000000n + 525000000000000n = 25525000000000000n Wei = 0.025525 ETH. Every step stays as integer Wei until display.
When and why it matters
Three classes of bugs trace to mishandling Wei. First: floating-point arithmetic on ETH values that silently rounds and causes “send 1.0 ETH” to leave 23 Wei stuck in the wallet, breaking later balance checks. Second: unit confusion (sending Gwei where Wei was expected, off by 10⁹) — the canonical embarrassing transaction is a $4,000 transfer that paid $4,000,000 in fees because a script multiplied gas price by 10⁹ twice. Third: copy-pasting a hex value field from an RPC response and parsing it as decimal — a transaction value of 0x4563918244F40000 is 5,000,000,000,000,000,000 Wei = 5 ETH, not 4,563,918,244,940,000 of anything. The defensive rules: keep all values as BigInt or BN.js wherever they live in code, label every variable with its unit (amountWei, not amount), and use ethers/viem helpers (parseEther, formatEther) at the human-display boundary only. Reference: ethers.js — About units.
Try the calculator
Convert between wei, gwei, and ETH with full 18-decimal precision.
Open the wei / gwei / ETH converter →Frequently asked questions
- What is a wei?
- A wei is the smallest indivisible unit of Ether (ETH), the native cryptocurrency of the Ethereum network. One ETH equals 10^18 wei -- that is, 1,000,000,000,000,000,000 wei.
- How is wei used in practice?
- Gas prices and smart-contract balances are calculated in wei at the protocol level. User-facing interfaces display values in gwei (10^9 wei) for gas prices or ETH for account balances. A typical base fee might be 10 gwei = 10,000,000,000 wei.
- What is the difference between wei, gwei, and ETH?
- Wei is the base unit (1), gwei is 10^9 wei and is used for gas prices (e.g. 20 gwei per unit of gas), and ETH is 10^18 wei, the human-facing denomination. The hierarchy mirrors the relationship between satoshis and BTC but with far more decimal places.
Related
Published May 14, 2026 · Last reviewed May 31, 2026