Before you delve into this article, I will recommend you to please go through this article to know more about Ethereum. This article solely focusses on the concept of Gas in Ethereum. We will learn about Gas in Ethereum- definition, why is Gas needed, transaction fee and concepts of Block Size, Base Fee, Priority Fee (Tip), Max Fee and major initiatives in the Ethereum space.

Definition-Gas Fees Ethereum

  • Each transaction in the Ethereum blockchain needs a fee to be processed. This fee is paid in Ether (cryptocurrency of Ethereum blockchain).
  • This fee helps in avoiding any spam transactions (because real money in terms of Ether is paid). It also assures prepaid rewards in Ether to the miners.
  • Fee in the Ethereum blockchain is paid in terms of Gas.
  • Gas is a unit of computational work. For example when we say we need 1000 Gas units for a transaction, it means that we need 1000 units of computational work to process the transaction.
  • Gas is paid in small amounts of Ether or wei.
    1 wei= 10^-9 gwei= 10^-18 Ether

Why is Gas needed?

Simply put, Gas is needed to make the Ethereum blockchain network secure.

To execute any transaction, computational resources are utilized in the Ethereum blockchain. If there is no limit to the computational resources to be utilized for a transaction, then malicious or some accidental transaction codes (loops or other computational wastage code) will use the limited computational resources, end them while other transactions keep waiting in queue.

Hence Ethereum has the concept of Gas. For each transaction, the user (or the user wallet) sets a Gas value or units of computations. Beyond this set Gas value the transaction will stop. If however, transaction is executed using lesser Gas, then the remaining Gas is refunded to the user.

Transaction Fee in Ethereum

Before the London Upgrade of August 2021

  • For every transaction, a STARTGAS value is given by the user or the node sending the transaction. This is the limit of computational work till when the transaction can be processed. If the computational work exceeds this STARTGAS value the transaction is stopped.
  • Also for every transaction the user specifies the cost for one unit of gas called GASPRICE. The higher you set the GASPRICE faster is the rate of your transaction being processed by a miner.
  • The product of the STARTGAS value and GASPRICE gives the transaction fee.
    Transaction Fee=STARTGAS*GASPRICE
  • For example, let us suppose that John wants to send 1 Ether to Trent. John sets a STARTGAS value of 21000. It means 21000 units of Gas is the limit of computational work that John has set for the transaction. Beyond this limit the transaction will stop.
    Also John sets the GASPRICE to be 200 gwei. Then the transaction fee will be STARTGAS multiplied by GASPRICE, i.e. 21000*200=4200000 gwei= 0.0042 Ether.

After the London Upgrade of August 2021

The London Upgrade of Ethereum Gas Fee, was implemented for three major reasons:

  • Better estimation of Transaction Fee.
  • Quicker inclusion of transaction in a block.
  • Offsetting the Ether issuance by burning a percentage of transaction fees.

Post the London Upgrade, every block in the Ethereum blockchain has a set BASEFEE which is the minimum fees that a user must pay in order to include a transaction in the block. The BASEFEE is decided basis the demand of base space at the time. This BASEFEE is burnt once the transaction is included in the block, to offset the issuance of Ether.

The user also includes a tip in addition to the BASEFEE to compensate the miner for executing and propagating the transaction in the block.

Now, the transaction fees is calculated as:

Transaction Fee = STARTGAS (No of units of Gas) * (BASEFEE + Tip)

(We will dig in greater detail about Base fee and Tip in the upcoming sections in this article).

Now suppose John wants to send one Ether to Trent. Let us assume the BASEFEE at the time (basis the demand for block space) is 100 wei. John sets a tip of 10 wei. The STARTGAS is 21000 units. The transaction fee will be calculated as:

Transaction Fee = 21000 * (100 + 10) = 2310000 wei = 0.00231 ETH

When John will send 1 ETH to Trent, 1.00231 ETH will be deducted from John’s wallet. 1 ETH will be credited to Trent’s wallet. From the rest 0.00231 ETH some will be paid to the miner and some will be burnt.

Block Size

Before the London Upgrade of August 2021, blocks in Ethereum had fixed sizes. At times of high demand, blocks were utilized to their full capacities and users had to wait for their transactions to be included in the next block. This resulted in a poor user experience.

After the London upgrade, size of blocks was kept variable. The target size of a block is 15 million Gas (i.e., transactions equivalent to 15 million units of computational work can be included in the block). The block size can be stretched up till a block limit of 30 million Gas (2 times the target block size).

Now the algorithm is designed such that if the size of the block (previous block in fact) is greater than the target block size of 15 million, the BASEFEE of the next block is increased. However, when the block size is lesser to the target block size the BASEFEE is decreased. This increase and decrease in the BASEFEE is proportional to how far the current block size is from the target block.

Base Fee

Some important points to notice and reiterate about BASEFEE:

  1. BASEFEE is generally represented in gwei (1 gwei = 10^-9 ETH)
  2. BASEFEE is the minimum fee per unit of Gas, that is required for a transaction to be included in a block. Hence, to include a transaction in a block, the offered fee per unit of Gas should be at least equal to or greater than the BASEFEE.
    Example: Let’s say the BASEFEE in a block is 100 gwei. Then the user should at least offer 100 gwei price for each unit of Gas for his/her transaction to be included in the block.
  • The BASEFEE of a given block in Ethereum is calculated basis the size of the previous block which in turn depends on the demand of block space at the given time.  Since the BASEFEE of a block depends on the previous block published, it makes it easy to predict the transaction fee for inclusion in a block.
  • If the size of the previous block is greater than the target size of 15 million Gas (high demand for block space), then the BASEFEE is increased, and if the size of the previous block is lesser than the target size, then the BASEFEE is decreased.
    The increase or decrease in the BASEFEE is proportional to the amount the size of the block is increased or decreased from the target size of 15 million Gas.
  • The Ether included as the BASEFEE is burnt to offset the issuance of too many Ether. The miner receives the tip fee.

Priority Fee (Tip)

As we mentioned earlier, a user includes a Priority Fee or Tip in addition to the BASEFEE. After the London Upgrade, the BASEFEE is burnt whereas the Tip is credited to the miner.

Greater the Tip, greater are the chances of your transaction being executed and included in a block by a Miner. This is obviously because a miner will look to work on a transaction which gives him/her the maximum reward.

Max Fee

This is an optional field. Here the users can specify a maximum limit of Ether or transaction fees they are ready to offer for a transaction to be executed.

It should always be greater than the sum of BASEFEE and Tip.

The difference between the MAXFEE and (BASEFEE + Tip) is refunded to the sender of the transaction.

Initiatives in Ethereum Space

The new network upgrades of Ethereum 2.0 (also known as Eth2 or Serenity) should ultimately address some of the gas fee issues, which will, in turn, enable the platform to process thousands of transactions per second and scale globally.

Layer 2 scaling is a primary initiative to greatly improve gas costs, user experience and scalability. More on layer 2 scaling.

The new proof-of-stake model, introduced on the Beacon Chain, should reduce high power consumption and reliance on specialized hardware. This chain will allow the decentralized Ethereum network to agree and keep the network secure, while limiting energy consumption by instead requiring a financial commitment.

Anyone with at least 32 ETH can stake them and become a validator responsible for processing transactions, validating blocks, and proposing new blocks to add to the chain. Users who have less than 32 ETH can join staking pools.

Ethereum Gas Fees Calculator

If you want to monitor gas prices, so you can send your ETH for less, you can use many different tools such as:

Conclusion

By now we have a firm understanding of Gas in Ethereum- definition, why is Gas needed, transaction fee and concepts of Block Size, Base Fee, Priority Fee (Tip), Max Fee and major initiatives in the Ethereum space.

Leave a Reply

Your email address will not be published. Required fields are marked *