Glossary

Wei

The smallest denomination of Ether, where one ETH equals 10^18 wei, named after cryptographer Wei Dai.

Key Takeaways

  • Wei is the smallest indivisible unit of Ether: 1 ETH equals 1,000,000,000,000,000,000 (1018) wei. All value calculations in Ethereum smart contracts and the EVM operate in wei to avoid floating-point errors.
  • Named after cryptographer Wei Dai, who created b-money in 1998: a precursor to Bitcoin that introduced decentralized digital cash concepts. Other Ethereum denominations like gwei (used for gas prices) and szabo also honor computing pioneers.
  • Analogous to Bitcoin's satoshi, but with far greater granularity: Ethereum supports 18 decimal places compared to Bitcoin's 8, making wei 10 billion times more fine-grained per whole coin.

What Is Wei?

Wei is the smallest and indivisible denomination of Ether (ETH) on the Ethereum network. Just as a dollar divides into 100 cents and a Bitcoin divides into 100 million satoshis, one Ether divides into 1018 wei. The Ethereum Yellow Paper, originally authored by Gavin Wood, defines all value references in the protocol as denominated in wei.

The unit is named after Wei Dai, a computer scientist and cryptographer who published the b-money proposal in 1998. B-money described an anonymous, distributed electronic cash system that introduced concepts like decentralized consensus and proof-of-work for currency generation: ideas that directly influenced Satoshi Nakamoto when designing Bitcoin a decade later. Dai also created the Crypto++ cryptographic library and co-proposed the VMAC message authentication algorithm.

In practice, users rarely interact with raw wei values. Wallets and interfaces display balances in ETH or gwei. But under the hood, every Ethereum transaction, smart contract, and protocol rule works exclusively in wei, ensuring deterministic integer arithmetic across all nodes.

How It Works

Ethereum defines a hierarchy of denominations, each a power-of-ten multiple of wei. Every denomination is named after a pioneer in computer science or cryptography:

Ethereum Denomination Table

UnitAlternate NameWei ValueNamed After
wei1 (100)Wei Dai: b-money creator
kweibabbage1,000 (103)Charles Babbage: computing pioneer
mweilovelace1,000,000 (106)Ada Lovelace: first programmer
gweishannon1,000,000,000 (109)Claude Shannon: information theory
microetherszabo1,000,000,000,000 (1012)Nick Szabo: smart contracts concept
millietherfinney1,000,000,000,000,000 (1015)Hal Finney: early Bitcoin developer
etherETH1018

Of these, only two denominations see regular everyday use: ETH for balances and transfers, and gwei for expressing gas fees. Gas prices typically range from single-digit to triple-digit gwei, making gwei the natural human-readable scale for fee discussions.

Wei vs. Satoshi

Both wei and satoshi serve as atomic units for their respective blockchains, but they differ significantly in granularity:

PropertyWei (ETH)Satoshi (BTC)
Units per coin1018108
Decimal places188
Granularity ratioWei is 10 billion times more divisible

Ethereum's deeper divisibility is intentional. Smart contracts often perform complex arithmetic involving token prices, interest rates, and proportional distributions. Eighteen decimal places provide enough precision for these calculations without overflowing standard 256-bit integers.

Why Integer Arithmetic Matters

The Ethereum Virtual Machine (EVM) has no floating-point support. All calculations use unsigned 256-bit integers. This is a deliberate design decision with three benefits:

  1. Determinism: floating-point results can vary between hardware implementations. Integer math is identical everywhere, which is essential for consensus.
  2. Precision: floating-point arithmetic introduces rounding errors. In financial systems, even tiny rounding differences can be exploited or can compound into significant discrepancies.
  3. Security: predictable arithmetic eliminates an entire class of vulnerabilities. Attackers cannot exploit floating-point edge cases if they do not exist.

By denominating everything in wei, Ethereum ensures that 0.1 ETH + 0.2 ETH always equals exactly 0.3 ETH: a guarantee that floating-point arithmetic famously cannot make.

Use Cases

Smart Contract Development

Solidity, Ethereum's primary smart contract language, natively understands wei and ether as unit literals. Developers use these to write clear, error-free value comparisons:

// Solidity wei and ether literals
uint256 public price = 0.05 ether;  // Compiles to 50000000000000000 wei
uint256 public minBid = 1000 gwei;  // Compiles to 1000000000000 wei

function withdraw() external {
    // All internal math uses wei integers
    uint256 fee = msg.value * 3 / 100;
    uint256 payout = msg.value - fee;
    payable(owner).transfer(fee);
    payable(msg.sender).transfer(payout);
}

The compiler converts human-readable units to wei at compile time. At runtime, every value is a raw integer in wei: no parsing, no conversion, no rounding.

Gas Fee Calculations

Ethereum's gas fee system, restructured by EIP-1559, uses wei as its underlying unit. The fee a transaction pays is calculated as:

Total Fee (wei) = Gas Units Used × (Base Fee + Priority Tip)

Example:
  Gas used:     21,000 units (simple ETH transfer)
  Base fee:     15 gwei = 15,000,000,000 wei
  Priority tip:  2 gwei =  2,000,000,000 wei

  Total = 21,000 × 17,000,000,000 = 357,000,000,000,000 wei
        = 0.000357 ETH

The base fee adjusts algorithmically per block based on network congestion. When block utilization exceeds the 50% target, the base fee increases by up to 12.5% per block. When below target, it decreases. The base fee is burned (permanently destroyed), while the priority tip goes to validators.

ERC-20 Token Precision

ERC-20 tokens follow the same integer-only pattern. Each token contract defines a decimals field that tells wallets how to display raw integer balances. Most tokens use 18 decimals to match ETH's wei precision, though stablecoins like USDC and USDT use 6 decimals to mirror fiat currency conventions.

// ERC-20 token with 18 decimals (standard)
// 1 TOKEN = 1,000,000,000,000,000,000 smallest units
// Analogous to 1 ETH = 10^18 wei

function decimals() public pure returns (uint8) {
    return 18;
}

// A transfer of "1.5 tokens" is internally:
// transfer(recipient, 1500000000000000000)

Developer Tooling

JavaScript libraries like ethers.js and web3.js provide conversion utilities because working with 18-digit integers in application code is error-prone:

// ethers.js conversion utilities
import { parseEther, formatEther, parseUnits } from "ethers";

// Human-readable to wei
const weiValue = parseEther("1.5");
// Result: 1500000000000000000n (BigInt)

// Wei to human-readable
const ethValue = formatEther(1500000000000000000n);
// Result: "1.5"

// Gwei conversions
const gasPrice = parseUnits("25", "gwei");
// Result: 25000000000n

Why It Matters

Wei is more than a unit of measurement: it reflects a fundamental design principle. By forcing all value handling into integer arithmetic at the protocol level, Ethereum eliminates precision bugs that have plagued traditional financial software for decades. Every smart contract, from simple transfers to complex DeFi protocols handling billions in value, inherits this safety guarantee.

For developers building on any blockchain, understanding atomic units is essential. Whether working with satoshis on Bitcoin, gas fees in gwei, or token amounts in their smallest denomination, the principle is the same: blockchains think in integers, and the atomic unit is the true currency of the protocol.

For a deeper look at how Ethereum's fee market works with these denominations, see the research article on EIP-4844 and blob fee markets.

Risks and Considerations

Precision Traps in Token Conversions

Not all ERC-20 tokens use 18 decimals. USDC uses 6, WBTC uses 8, and some tokens use non-standard values. Assuming 18 decimals when interacting with an unknown token can produce values off by factors of trillions. Smart contracts and applications must always read the decimals() function before performing conversions.

Integer Division Truncation

While integer arithmetic avoids floating-point errors, it introduces its own hazard: division truncates rather than rounds. In Solidity, 5 / 3 equals 1, not 1.666.... For operations involving proportional splits, fees, or interest calculations, the order of operations matters. Multiplying before dividing preserves more precision than dividing first.

// Precision loss from division order
uint256 amount = 1000;

// Bad: divide first, lose precision
uint256 bad = (amount / 3) * 2;   // = 333 * 2 = 666

// Better: multiply first, preserve precision
uint256 good = (amount * 2) / 3;  // = 2000 / 3 = 666

// In this case results match, but with different
// values the rounding error compounds significantly

Human Readability Challenges

Raw wei values are difficult for humans to parse. A balance of 1,500,000,000,000,000,000 wei is simply 1.5 ETH, but displaying or logging raw values during debugging can lead to mistakes. Off-by-one errors in the number of zeros are a common source of bugs in smart contract development and integration code.

Cross-Chain Denomination Differences

Different blockchains use different decimal precisions. Bridging assets between chains with mismatched precision (for example, moving a token with 18 decimals to a chain that supports only 8) can cause precision decay: permanent loss of the least-significant digits. Developers working across chains must account for these differences in their conversion logic.

This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.