What is WEI?
What is WEI?
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.
Unit | Alternative Name | Wei Value | Gwei Value | Ether 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 |
What are the denominations of Wei?
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.
What is Gwei?
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.
How to Convert Wei to Gwei
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:
Count the number of amount of wei
Use a base divisor of 10^9 or 1 billion
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.
How to Convert Wei to ETH
Similar to converting Wei to Gwei, users can use a wei converter or follow a 3-step conversion process:
Count the quantity of wei in total
Use a base divisor of 10^18 or 1 quintillion
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.
How to Convert Wei to ETH from Code
Here's how to convert ETH to gwei using the Alchemy SDK:
Install the alchemy SDK
Enter or retrieve the amount you want to convert
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:
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();
Related articles
Fostering an Open Ecosystem
Alchemy’s mission is to bring the next billion users onchain. Getting there will require a fast-growing ecosystem of projects working to build the future of web3.
2023 Web3 Development Report
Web3 developer activity reaches all-time-highs as new rollup frameworks and account abstraction take root.
Arbitrum Account Abstraction Workshop Series
Arbitrum and Alchemy are partnering together to bring you an exciting new educational series on Account Abstraction!