0%
HomeBlogLearn
What is WEI?

What is WEI?

Author: Brady Werkheiser

Reviewed by Logan Ross


Published on August 3, 20233 min read

Wei is the smallest denomination of ether, the currency used to facilitate transactional operations on the Ethereum blockchain network, where 10^18 or 1,000,000,000,000,000,000 wei is equivalent to one ether.

Wei is named after Wei Dai, a computer science graduate of the University of Washington who formerly worked in the cryptography research department at Microsoft. Wei Dai was part of a cypherpunk movement in the 1990s whose members developed the theoretical underpinnings for cryptocurrencies in the 2010s. For his innovation of bmoney, discussed in a self-published proto-crypto manifesto which laid the foundation for smart contracts, the atomic unit of ether is named after him.

Since all services and applications built on top of the Ethereum network require computational power, which is not freely available, some form of payment for the computational power is required.

Although ether is the currency of the network, it is often metaphorically referred to as the “fuel” of the Ethereum network. Its utility value as a cryptofuel is commonly referred to as “gas”.

Gas is a core part of all network requests and the sender of requests is required to pay for consumed computing resources. The overall gas cost is calculated based on both the volume and complexity of the request multiplied by the current gas price.

UnitAlternative NameWei ValueGwei ValueEther Value

Wei

Wei

1 Wei

10^-9 Gwei

10^-18 ETH

Kwei

Babbage

10^3 Wei

10^-6 Gwei

10^-15 ETH

Mwei

Lovelace

10^6 Wei

10^-3 Gwei

10^-12 ETH

Gwei

Shannon

10^9 Wei

1 Gwei

10^-9 ETH

Twei

Szabo

10^12 Wei

10^3 Gwei

10^-6 ETH

Pwei

Finney

10^15 Wei

10^6 Gwei

10^-3 ETH

Ether

10^18 Wei

10^9 Gwei

1 ETH

While the US dollar can only be divided into 100 equal parts i.e. into pennies, cryptocurrencies can be divided into much smaller atomic units. 

These units ensure appropriate denotation of ether that may appear to be relatively small but is in fact a larger amount when converted to US dollars or other major currencies. 

Therefore, ether has multiple different levels of wei. Each subunit indicates the quantity of units but as mentioned above, have alternative names.

Gwei, a blend of the words wei and giga, a unit prefix for billion, is another denomination of ether, the digital currency used on the Ethereum blockchain network. There are 1 billion wei in one gwei and there are 10^9 or 1,000,000,000 gwei in one ether. Gwei is also referred to as nanoether or Shannon, after Claude Shannon, a prominent American mathematician and cryptographer who’s regarded as the father of information theory. 

By virtue of how gas prices function and are denoted, Gwei is the most commonly used unit of ether. As gas is the pricing value deemed necessary to execute a contract or other form of transaction on the Ethereum network, gwei is needed to pay for the computational power. 

The standard transaction fee is 21,000 gwei on the Ethereum blockchain network. Typically, transaction fees will rise proportionately to the underlying complexity of the transaction 

In July 2021, as part of the London Hard Fork, Ethereum Investment Proposal (EIP) 1559 changed the Ethereum blockchain network’s fee mechanism. Formerly, developers and the broader ecosystem had to rely upon a price auction, where the highest bidder would have their transaction processed first. 

With the introduction of EIP-1559, a discrete base-fee would be registered for transactions to be included in the next block. Nevertheless, certain individuals can add a “tip” or “priority fee” to ensure a miner prioritizes their transaction. Developers interested in a deeper understanding of how to send transactions using EIP-1559 can read Alchemy’s EIP-1559 documentation. 

The methodology to calculate the transaction fee is by using the following formula: 

Gas Units (Limit) x (Base Fee + Tip)

Ultimately, fees based on block demand are far more straightforward and transparent for users today. In addition, developers can build a gas-fee estimator using EIP-1559 methods through Alchemy. 

The three steps for converting wei to gwei is to divide the total amount of wei by 1 billion.

Developers can use a conversion calculator to understand the relationship between wei and gwei, or follow this simple step-by-step process: 

  1. Count the number of amount of wei

  2. Use a base divisor of 10^9 or 1 billion 

  3. Divide the number of wei by the base divisor

This will give you the overall number of gwei.

For example, 420,069,000,000 wei / 1,000,000,000 = 420.069 gwei.

To calculate the price in terms of USD, multiply your total gwei by the current price of one Ether divided by 1,000,000,000 (10^9).

For example, if Ether is worth $1,000, then 420.069 gwei equals $0.000420069, or approximately 1/25th of one cent.

Similar to converting Wei to Gwei, users can use a wei converter or follow a 3-step conversion process:

  1. Count the quantity of wei in total

  2. Use a base divisor of 10^18 or 1 quintillion

  3. Divide the number of wei by the base divisor.

This will give you the total amount of ETH.

For example 100 trillion wei / 10^18 = 0.0001 ETH.

To calculate the price in terms of USD, multiply your ETH by the current price of ETH.
For example, 0.0001 ETH is equal to $0.10 when 1 ETH costs $1,000 USD.

Here's how to convert ETH to gwei using the Alchemy SDK:

  1. Install the alchemy SDK

  2. Enter or retrieve the amount you want to convert

  3. Call the formatEther method to convert to ETH

Here’s an example of how to get the ether balance from vitalik.eth (returned in gwei) and print it out in terms of ETH:

Copied
const { Alchemy, Utils } = require('alchemy-sdk'); const alchemy = new Alchemy(); const main = async () => { // Set wallet address const address = 'vitalik.eth'; // Get balance and format in terms of ETH let balance = await alchemy.core.getBalance(address, 'latest'); balance = Utils.formatEther(balance); // convert it to Ether console.log(`Balance of ${address}: ${balance} ETH`); } main();
Desktop section background image

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get your API key