Top Leaderboard
Markets

Wei

Ad — article-top

Key takeaways
– Wei is the smallest (atomic) unit of ether (ETH), the native cryptocurrency of the Ethereum blockchain.
– 1 ether = 1,000,000,000,000,000,000 wei = 10^18 wei. Equivalently, 1 wei = 10^-18 ETH.
– Developers and users typically work with larger subunits such as gwei (10^9 wei) because wei amounts are extremely small.
– Gas costs on Ethereum are usually quoted and paid in gwei (or in wei under the hood), so understanding conversion between ETH, gwei, and wei is essential for estimating transaction costs.
– Named after cryptographer Wei Dai, who contributed early ideas to cryptography and cryptocurrencies.

How wei works
– Purpose: Wei is the atomic denomination for ETH, analogous to the cent for the U.S. dollar but many orders of magnitude smaller. It prevents fractional rounding issues and provides precise accounting for tiny transfers or fees.
– Relationship to ETH: All on‑chain balances and computations use wei as the base unit. Wallets and user interfaces convert to ETH (or other human-readable units) for display.
– Common subunits:
• wei = 10^0 wei = 1 wei
• kwei (babbage) = 10^3 wei
• mwei (lovelace) = 10^6 wei
• gwei (shannon) = 10^9 wei — most common for gas prices
• microether (szabo) = 10^12 wei
• milliether (finney) = 10^15 wei
• ether = 10^18 wei

The wei’s exemplar (origin and naming)
– The unit is named after Wei Dai, an early cypherpunk and cryptography researcher who proposed b-money, an influential early concept in digital money and smart contracts. (See Investopedia; other crypto history sources discuss Wei Dai and b-money.)

How much is 1 wei of Ether?
– Exact definition: 1 wei = 10^-18 ETH.
– Convert to USD: The USD value of one wei = (ETH price in USD) / 10^18.
• Example (from the Investopedia snapshot): If 1 ETH = $3,456.14, then 1 wei ≈ $0.000000000000003456 (3.456 × 10^-15 USD). Note: ETH price fluctuates; always use current market prices.

What is the difference between wei and gas?
– Wei is a denomination (unit) of ether. Gas is a unitless measure of computational work performed by the Ethereum network.
– How they combine: Gas used by a transaction is multiplied by a gas price (expressed in gwei/wei) to get the fee in wei, which is then transferred as ETH.
• Transaction fee (in wei) = gas used × gas price (in wei per gas).
• Transaction fee (in ETH) = (gas used × gas price in wei) / 10^18.
– Practical note: Gas units measure execution work (e.g., 21,000 gas for a standard ETH transfer). Gas price (in gwei) is set by the sender and determines how quickly miners/validators are likely to include the transaction.

Practical conversions and examples

1) Basic ETH ↔ wei conversion
– To convert ETH to wei: multiply by 10^18.
• Example: 2.5 ETH × 10^18 = 2,500,000,000,000,000,000 wei.
– To convert wei to ETH: divide by 10^18.
• Example: 1,000,000,000 wei ÷ 10^18 = 0.000000001 ETH = 1 gwei.

2) Gwei conversions (common for gas)
– 1 gwei = 10^9 wei = 10^-9 ETH.
– Example gas cost calculation:
• Gas limit for a simple transfer: 21,000 gas.
• Gas price: 100 gwei (100 × 10^9 wei).
• Fee in wei = 21,000 × 100 × 10^9 = 2,100,000,000,000,000 wei.
• Fee in ETH = 2,100,000,000,000,000 / 10^18 = 0.0021 ETH.

3) Step-by-step: calculate Ether cost in USD for a transaction
– Step 1: Determine gas used (or gas limit) and chosen gas price (in gwei).
– Step 2: Convert gas price to wei: gas_price_gwei × 10^9 = gas_price_wei.
– Step 3: Multiply: fee_wei = gas_used × gas_price_wei.
– Step 4: Convert wei to ETH: fee_eth = fee_wei / 10^18.
– Step 5: Multiply by current ETH/USD price: fee_usd = fee_eth × ETH_price_usd.

Tools and practical steps for users and developers

A) For end users (wallets, estimating fees)
– Use wallet UI: Most wallets show estimated fees in ETH or USD and let you pick “slow / average / fast” which correspond to different gas prices. This is simplest and recommended for nontechnical users.
– Check live gas price trackers (e.g., Etherscan gas tracker, Gas Now, or your wallet’s recommended values) to choose an appropriate gas price in gwei.
– If you want exact math: follow the conversion steps above to compute the fee.

B) For developers (programmatic conversions)
– JavaScript (ethers.js):
• Convert ETH to wei: ethers.utils.parseUnits(“2.5”, “ether”) → BigNumber (2.5 × 10^18 wei).
• Convert wei to ETH: ethers.utils.formatUnits(bigNumberWei, “ether”).
• Convert gwei: ethers.utils.parseUnits(“100”, “gwei”) → returns wei.
– JavaScript (web3.js):
• web3.utils.toWei(“2.5”, “ether”)
• web3.utils.fromWei(weiValue, “ether”) or “gwei”
– Command-line or spreadsheets:
• Multiply/divide by 10^18 (watch for big integers — many languages require bigint or arbitrary-precision libraries).

C) Common pitfalls to avoid
– Rounding errors: don’t use floating-point numbers for wei; use integer arithmetic and big-number libraries.
– Wrong unit: confusing ETH with gwei or wei will produce transaction errors and unexpected fees.
– Gas estimation: always use estimated gas or safe margin; out-of-gas causes transaction revert though you still pay fees for gas used up to revert.

What is 2.5 Ether to wei?
– Calculation: 2.5 ETH × 10^18 wei/ETH = 2,500,000,000,000,000,000 wei.
– Use big-integer or library functions in code to represent this exactly.

The bottom line
– Wei is the atomic accounting unit on Ethereum; 10^18 wei = 1 ETH. For everyday use, gwei is the most convenient unit to read gas prices and compute fees. Always convert using integer math or reliable libraries, and check current ETH/USD prices and live gas estimates when planning transactions.

Related topics and further reading
– Ethereum (ETH) basics and tokens
– Gas, gas price, and gas limit
– Gwei and other Ethereum denominations
– Wei Dai and the history of digital cash / b-money

Sources
– Investopedia: “Wei”
– BitcoinWiki: “Wei Dai” (general background on Wei Dai and b-money)

Editor’s note: The following topics are reserved for upcoming updates and will be expanded with detailed examples and datasets.

Ad — article-mid