What is Wei?

1 min read Updated

Wei is the smallest denomination of Ether (ETH), where 1 ETH = 10^18 wei — used in smart contract programming and RPC calls where values must be expressed as integers without decimal points.

WHY IT MATTERS

Blockchains don't use floating-point numbers — they use integers for precision. Wei is ETH's base unit: 1 ETH = 1,000,000,000,000,000,000 wei. All on-chain values, RPC calls, and smart contract interactions use wei.

Named after Wei Dai (cryptographer and cypherpunk), wei enables precise calculations without rounding errors that floating-point math would introduce. This precision is critical when handling financial values.

Developers must constantly convert between human-readable ETH values and wei for contract interactions. Libraries like ethers.js provide parseEther/formatEther utilities for this conversion.

FREQUENTLY ASKED QUESTIONS

Why not just use ETH as the unit?
ETH has 18 decimal places. Smart contracts use integers for precision — no floating-point rounding errors. Wei (integer) eliminates the precision issues that decimals introduce.
What's the conversion?
1 ETH = 10^18 wei. 1 gwei = 10^9 wei. 1 ETH = 10^9 gwei. Gas prices are typically expressed in gwei (e.g., '20 gwei per gas').
Do other tokens use wei?
ERC-20 tokens define their own decimals. USDC uses 6 decimals (1 USDC = 10^6 units). WBTC uses 8. Always check a token's decimals before doing math.

FURTHER READING

Enforce policies on every tool call

Intercept is the open-source MCP proxy that enforces YAML policies on AI agent tool calls. No code changes needed.

npx -y @policylayer/intercept
github.com/policylayer/intercept →
// GET IN TOUCH

Have a question or want to learn more? Send us a message.

Message sent.

We'll get back to you soon.