How Are Gas Fees Calculated on Ethereum?

By Dhirendra Das
8 Min Read

Gas fees on Ethereum basically comprises three components: the gas limit, the base fee and the priority fee. The fee is calculated by multiplying the gas limit with the sum of the base fee and the priority fee. Together, these units make the gas fee that is utilized to add a transaction on the blockchain.

In this article, we will explore the meaning of these individual components and also understand how they add up to make the gas fee. We will use the reference of Ethereum as a blockchain. 

Do you know Ethereum is a public blockchain, and there are private blockchains as well?

Understanding The Concept and Working of Gas

The Concept

Gas is the measure of how much work needs to be done by validators to verify your transaction and add it to the blockchain.

In technical terms, gas is the energy required to introduce a state change in the blockchain.

In Ethereum and other blockchains based on it, gas is denoted with Gwei or Giga-wei. Wei is the smallest unit of Ethereum, and Gwei means 1 Giga wei, which converts to 0.000000001 ETH (or 1 ETH = 1 billion Gwei).

Working in Brief

In Ethereum, gas is typically auctioned which means those who want to send a transaction on the Ethereum blockchain must compete with others to buy gas. Hence, when there are more transactions, the gas prices increase due to competitive bidding and when the network has lesser transactions, the gas prices are low.

Also, each Ethereum block has a gas limit for the entire block, which is currently 30 million Gwei. As soon as the total gas fee paid for the block surpasses this limit, the base fee required to clear a transaction is raised. This discourages competitive bidding for gas and allows the network to de-clog.

The above concept can be understood better with the following diagram where dark areas represent congested networks and lighter areas denote low network traffic.

gas stamp
Gas Price Heat Map.

Note that the gas prices are relatively higher during midday UTC as this is the period when there is maximum activity from all over the world.

A guide to understanding all the fees in crypto and blockchain.

Gas Fee Calculations

The present formula for calculating gas fees was finalized after the London hard fork. It includes three factors: gas limit, base fee, and priority fee.

Gas Fee = (gas limit) x (base fee + priority fee)

  • Gas limits are the units of “gas” consumed to validate and add a transaction to the network. These are precise values and even if you set this value higher, the extra gas is credited back to your account.
  • The base fee is the minimum fee required to ensure your transaction is considered valid on Ethereum. This is the fee denoted in gwei when you open any gas tracker. For example, in the below diagram, the base fee is 5 Gwei.
gas details
Ethereum Gas Fee Tracker.
  • Priority Fee is the extra fee to push the transactions faster. This extra fee is paid to validators so they quickly pick up the transaction and execute it faster.

During gas wars, this fee is often increased to high limits so that users can get their transactions processed faster. Gas wars usually occur when multiple users try to transact before each other due to reasons such as NFT minting, to claim airdrops or any other urgency.

Why Did the Ethereum Gas Fee Crash to 1 Gwei?

The base fee on Ethereum crashed to 1 Gwei on the 22nd of June 2024 due to the introduction of various scaling upgrades.

Do you know? With the Ethereum gas fee crashing, the layer-2 fees have crashed even further. 

Ethereum implemented the Dencun Upgrade on 13th March, which introduced a temporary storage feature called the blobs. Top gas buyers such as Uniswap, Tether, Circle, and layer-3 solutions then began using these “blobs” to rollup transactions into batches. 

Prior to this, Ethereum transaction costs could even reach hundreds of dollars.

Earlier, they used to verify these transactions individually. Since these protocols used a lot of gas, switching to “blobs” made transactions cheaper for them.

Ultimately, due to freed gas for others, the base fee got reduced which ultimately led to low gas prices.

7 day history
Gas Fee Tracker.

Note: The base fee is the biggest component in gas fee calculations.

Why Is My Transaction Stuck?

Sometimes, when you set your gas limits way too low, the transaction gets stuck. This is because, at a given point in time, the network needs a definite amount of gas to validate and add your transaction to the blockchain.

First, make sure you know how to check a transaction on Ethereum.

A stuck transaction has happened several times while we were testing low-gas transactions after the Dencun Upgrade. 

  1. You can speed up the transaction as soon as you see that your network has delayed sending the transaction, possibly due to low gas. On MetaMask, this feature is present just below the transaction details under the Queue tab.
metamask
Speeding-up Stuck Ethereum Transactions
  1. On the next screen, adjust the gas limit accordingly. Remember, an average transaction requires around 21,000 gas, which may increase to higher limits during gas wars and network congestion.
speed up transactions
Speeding up a Spent Transaction on MetaMask
  1. As an additional measure, you can also increase the Priority Fee by around 5 Gwei, which can then de-clog the network and send your transaction with the highest priority. 
  2. Click Save, and the transaction will be resolved within the next few minutes.

If the problem still persists, contact your wallet’s support team.

Conclusion

Gas fee is calculated based on two factors, the base fee, and the priority fee. Both of these factors are multiplied by “gas limit” to obtain the total gas fee in Gwei, which is one-billionth of an ETH. The base fee is the minimum fee that needs to be paid, and the priority fee is paid to speed up the transactions. 

Sometimes, if the gas limit is set too low, the transactions might get stuck and can be de-clogged by adding more gas to the transaction. 

Dhirendra Das has been an active crypto trader and journalist since 2020. He spent most of his career as an SEO for blockchain native companies and holds an MBA Finance degree from Jain University.