Lily R.
Lily R.
Mar 05, 2022

What Is Ethereum Gas?

#cryptography#defi#education#eth
tl;drYou have probably noticed people complaining about how expensive operations are on Ethereum because of the gas fee. But what is Ethereum gas, and how is it calculated? To learn about Ethereum gas, we need to know how Ethereum works. Keep scrolling to learn it all.
What Is Ethereum Gas?
What Is Ethereum Gas?
How do you rate this post?
Good
Average

What Is Ethereum?

In simple terms, Ethereum is programmable money. It is a DIY (Do It Yourself) platform for decentralised applications and programs. Ethereum’s goal is to move decentralisation one step further - not just decentralising money like Bitcoin did, but decentralising the Internet itself. It does so by introducing smart contracts, which are contracts run by codes and can be programmed to do various tasks. Ethereum is not a currency; it is a platform, and Ether is its currency. Now let’s see what the gas fee is.

What Is Ethereum Gas Fee?

Ethereum gas is like fuel to the car. To run the car, you need fuel, and to run Ethereum’s smart contracts, you need gas. It is not literally gas! It is called gas because it’s like fuel that powers the code and allows the network to operate. The gas mechanism is highly efficient since it makes people pay for the code to run, and it prevents unnecessary traffic on the network. Ethereum gas fee is a price determined by the demand for computing power on the network and how much traffic the network is handling. The amount of gas you need for a certain action is determined by two factors: how big of a contract you’re trying to execute and how fast you want it executed. If you're okay with waiting a little longer, you can pay less gas, or if you wish your contract or transaction to be executed ASAP, you need to pay more gas fees.

Transaction Speed on Ethereum Blockchain

Since Ethereum currently uses the PoW (Proof of Work) consensus mechanism, the transactions are validated by miners. Ethereum miners can only validate a certain number of transactions per block and get the gas fees as rewards. This is actually why you get to choose how fast you want your transaction to be executed. Because if the transaction is completed slowly, it may not be validated as quickly as you want it to, and it might take hours or even days. You can pay more gas fees to incentivise the miners to validate your transaction ahead of other transactions. Depending on how much you’re willing to spend on your gas fee, your transaction can take from seconds up to hours to be executed.

How Is Ethereum Gas Fee Calculated?

The calculation of Ethereum gas changed after the London hard fork on Aug 5, 2021, to make the gas fee more predictable for users and decrease its volatility. Learn key points on forks in crypto.

The London upgrade, AKA Ethereum Improvement Protocol 1559 or EIP -1559, is a part of a very significant and much-awaited upgrade that has been pushed back to June 2022. The upgrade is known as Ethereum 2.0, which aims to solve Ethereum’s scalability issues and transfer from Proof-of-Work (PoW) consensus mechanism to Proof-of-Stake (PoS) consensus mechanism. We’ve explained all about PoW and PoS here.

Gas Fee Calculation Before EIP-1559

Before the London hard fork, gas was calculated via the following formula:

Gas fee = Gas units (limit) x Gas price per unit

The gas limit or unit never changes for a certain action; for example, it is fixed on 21,000 for a simple Ether transaction and 400 units to check the balance. For more complicated transactions such as doing things with smart contracts, the gas limit is higher. The number of gas limit is fixed, so no matter if the price of Ethereum crashes or pumps, prices for certain actions won’t change drastically. However, the gas price per unit does change.

I Want Faster Transactions!

If you want your transaction to be completed by the miners faster, you can increase the gas. The fees do not depend on how much you're sending; they only depend on the complexity of your transaction (e.g. just sending Ether is relatively cheap, but calling some smart contracts, like an Automated Market Maker (AMM) or ERC-20 token, will be a bit more expensive). To find out how much an operation will cost in dollars, we need to multiply the gas by the price of gas in dollars. This is where the unit, gwei, comes into play.

What Are Gwei And Wei?

To learn how the Ethereum gas fee calculation happens, let’s open a small parenthesis and see what these units are. Gwei stands for gigawei. Wei to Ether is what one Satoshi is to one Bitcoin. One Ether equals one quintillion weis (1018), and since that’s a tiny number, we use gigawei instead. One gigawei is 0.000000001 Ether. Wei was named after Wei Dai, a Chinese computer scientist best known for his contributions to cryptography, like creating the Bitcoin predecessor "b-money" and developing the Crypto++ library. Don’t you know what cryptography is? Follow me to learn then!

Gas Fee Calculation: A Practical Example

Let’s analyse a simple transaction to better wrap our heads around it. Let’s say you want to transfer 1 ETH to another wallet. The gas limit is 21,000 for a simple ETH transaction like this, and the gas price per unit is 200 gwei at the moment. By using the formula given above, the total fee is calculated as 21,000 x 200 = 4,200,000 gwei, or 0.0042 ETH. When the transaction is done, 1.0042 ETH is subtracted from your wallet, the other wallet receives 1 ETH, and a miner receives 0.0042 ETH. Learn pro tips on choosing wallets.

Gas Fee Calculation After EIP-1559

The London upgrade introduced a burn mechanism of Ether, which is intended to offset the issuance of new ETH (there is no limit to how many ETH can be minted). With this upgrade, each block has a base fee, which is calculated based on how crowded the network is at that moment. The base fee will burn later, and instead, users need to include a miner’s tip with each transaction. If the tip is higher, their transaction will possibly be prioritised. This is how gas is calculated like after EIP-1559 implementation:

Gas units (limit) x (Base fee + Tip)

An Example of Gas Fee Calculation After EIP-1559

Imagine you want to send 1 ETH to another wallet. The transaction limit is 21,000 units, and the base fee is 100 gwei. You also include a tip of 10 gwei. By taking a look at the formula, the calculation is as follows: 21,000 x (100 + 10) = 2,310,000 gwei or 0.00231 ETH. After the transaction is done, 1.00231 is subtracted from your wallet, and the other wallet will receive 1 ETH. The miner’s tip would be 0.00021 ETH, and 0.0021 ETH is burned.

What Is Max Fee?

You can also set a max fee for your transaction, and the difference between the max fee and the actual fee will be refunded to your wallet. This way, users can set a max amount to pay for transactions without overpaying (the issue that frequently happened before the London hard fork). If you don’t want to go through all the pain and calculation, you can check out this website for a live chart of Ethereum’s gas price. Tada!

Conclusion

There are times Ethereum's network gets overwhelmed by the number of transactions and operations going on, and the price of gas skyrockets. Ethereum aims to solve this scalability issue with the Ethereum 2.0 update. At Cryptologi.st, you can find answers to all your crypto questions because we provide educational posts, hot news, coin reviews, and investment options. We have got all your crypto needs covered!

How do you rate this post?
Good
Average
0