What’s Gas Fee?

BeginnerNov 21, 2022
The gas fee refers to the fee you need to pay to get access to blockchain services. Reflecting the cost of limited resources on the blockchain network, the gas fee can help set a fair price for transaction calculation and execution of smart contract code.
 What’s Gas Fee?

Introduction

Cryptocurrency and blockchain technology have brought many changes to traditional finance. The autorun codes, transparent consensus mechanisms, and decentralized ledgers allow users to transfer the value of cryptocurrencies and exchange resources without going through a trusted third party, greatly cutting the cost of financial services and enhancing the efficiency of human economic activities.

However, lower costs do not mean that there are no fees at all. When the blockchain network helps users get what they need, they still need to invest resources to complete these tasks. As the saying goes, there ain’t no such thing as a free lunch. Users need to pay some fees to enjoy the services of the blockchain and keep it running constantly. The fee is generally called the gas fee. This article will show you what a gas fee is.

About the Gas Fee

In the blockchain field, the term gas fee was first used in Ethereum. It refers to the fees required for transactions on Ethereum, which are conceptually the same as the transaction fees paid by Bitcoin miners. Since every transaction in Ethereum requires computational resources to execute, users need to pay for the service in order to compensate the participants who assist with verification. Then, many other blockchain protocols follow suit. That’s why the fee paid for the network service is also called the gas fee.

Gas fees can be compared to fuel that a vehicle needs. Without fuel, a vehicle will be unable to travel from city A to city B. By providing gas fees to Ethereum, the nodes on the blockchain network can help users to transfer funds, trade, execute smart contract codes, etc. Therefore, Gas is the fuel in the Ethereum network that promotes the operation of the blockchain network.

Just as the amount of fuel determines the distance a car can travel, what Ethereum’s Gas measures is the unit of computation power required to perform a specific operation. Simple services require less gas, while complex smart contract operations require more Gas to complete. The Gas fee is usually denominated in the native assets of the blockchain network. It is represented by gwei on Ethereum, which means giga-wei (1,000,000,000 wei). Wei is the smallest unit of ETH tokens. You can find the common ETH calculation units in the following table:

Why is the gas fee necessary?

Nobody likes to pay, so why do users need to pay gas fees to use Ethereum? Wouldn’t it be nice to browse for free, just like the internet? If you’ve ever had a similar thought, imagine what would happen if Ethereum’s services were free.

  1. Ethereum will be more vulnerable to hackers.

Not having to pay means that hackers can launch an attack at almost zero cost, making the blockchain network insecure.

  1. Abuse of limited network bandwidth resources.

Robots can send a lot of junk transactions on the blockchain. That is, they can affect users who really need to use it without paying any price for malicious behavior.

  1. The system will crash due to the unrestricted operation of nodes.

For example, when an error occurs in the automatic execution of the smart contract code deployed on a node and an infinite loop occurs, the node will be paralyzed due to a large number of repeated operations, and even affect the operation of the entire blockchain network. Increasing the execution condition of the Gas Fee will ensure that no such problems arise.

  1. Result in inefficient applications.

No Gas Fee means that developers do not have to consider whether the amount of computation is reasonable, and users will have a worse service experience due to a large number of inefficient codes.

  1. No incentives will result in the unwillingness of participants to continue operating.

To execute transactions and smart contracts, users need to purchase equipment that needs electricity to operate, and needs to be repaired or replaced in the event of a failure. That’s, users need to pay for electricity, repair, and replacement. It can be said that everything that builds a blockchain network requires money. If the operator can’t get any benefits from it, who would be willing to participate?

In short, nothing is truly free of charge. Even for the seemingly free Internet, ISP service providers need to set up submarine cables, websites need servers, and employees need salaries… These are real expenses. The so-called “free” is only realized through advertising, traffic, and other ways to obtain resources that continue to provide services. Users must give back to the blockchain network that generates value for them, and the introduction of the concept of a Gas Fee can maintain such a layer of unique value.

How Ethereum’s Gas fee works

Users need to pay the Gas fee to access the services of the blockchain network. So how is the Gas fee calculated? Well, different protocols have different methods, but generally follow a simple formula:

Total Gas Fee = Gas units (limit) * Gas price per unit

This calculation of Gas Fee is quite intuitive. It is like calculating the fuel costs for a vehicle journey driving from city A to city B today. To get the answer, we need to have the number of liters of gasoline consumed multiplied by the current oil price. At the same time, the farther you travel (the higher the difficulty of the task), the more liters of gas consumed (the higher the Gas Used). Before the London upgrade in August 2021, the Gas Fee in Ethereum is also calculated in the same way as the above formula:

Total Gas Fee = Gas units (limit) * Gas price per unit

For example, if Alice wants to pay Bob one ETH, the Gas Units required in such a simple transaction is 21000, and the Gas Price at the time of payment is 200 gwei, then the calculation is:

Gas Fee = 21000 * 200 gwei = 4200000 gwei = 0.0042 ETH

When Alice uses the Ethereum network to pay, 1.0042 ETH will be debited from her account, while Bob will receive 1 ETH, and the miner responsible for packaging the transaction will receive 0.0042 ETH.

EIP 1559 Fee Improvement Proposal

In August 2021, after the London upgrade of Ethereum, the calculation method of the Gas fee changed, but the overall logic remains the same:

Total Gas Fee = Gas units (limit) * (Base fee + Priority fee)

https://etherscan.io/gastracker

What is the Base fee?

The Base fee refers to the base rate at which the proposed transaction is packaged into the block by miners, and is also the minimum consumption rate for using the Ethereum network. The price of the base rate is not related to the block currently waiting to be packaged but is determined by the previous block, which will make Ethereum’s Gas Fee more transparent and predictable for users.

The level of the base fee can be calculated by a formula. If the total amount of Gas used for all transactions in the previous block is higher than the target value, the base fee of the next block will increase by up to 12.5%. Exponentially rising with the total high gas of consecutive blocks, prolonged blockchain network congestion will result in a very high base rate, and users will reduce usage in the end because they cannot afford it.

For example, after the London upgrade, the total target Gas in each block of Ethereum is 15 million Gas, while the upper limit is 30 million Gas. If there is a series of 30 million Gas in total after the block with 15 million Gas in total, the Base fee will continue to increase:

The base fee only doubles after 8 blocks. It seems that the increase is small. But if we assume that 80 consecutive blocks reach the gas limit, the base fee will increase by 10,000 times, from 100 gwei to 1 million gwei.

Before the London upgrade, miners on the Ethereum blockchain could receive the gas fee for all transactions included in a block. However, after the London upgrade, the ETH used to pay the base fee when new blocks are mined will be burned, removing it from the total circulating supply of ETH, resulting in deflation and an increase in the price of ETH.

What is the priority fee?

The burning of base fees reduced the income of miners. Therefore, the London upgrade introduced the concept of priority fees (often called tips) to incentivize miners to include transactions in block packaging.

Users might be thinking: they have all paid the base rate but why do they even have to tip the miners? This starts with the question of economic incentives. Packing pending transactions are resource intensive. The income for these miners to keep Ethereum running comes from new block rewards and tips. Without tips, they would find that there are no transactions to pack. Empty blocks and blocks containing pending transactions generate the same revenue. Since the result is the same, why spend resources to package pending transactions? Assuming that all participants go to pack empty blocks, the blockchain network will also be unusable.

Therefore, tips for miners will be the most basic incentive for them to perform work correctly. They will be willing to prioritize transactions with higher tips. Since the level of the tip affects the order in which transactions are processed, it is called a priority fee. For urgent transaction needs, users can submit higher tips to gain priority.

This does not mean that the user has to be ripped off first by paying a large tip before completing the transaction. For transactions that are not time-sensitive, the transaction will be packaged and processed in the next few blocks as long as the gas fee paid is slightly higher than the base fee and the miner is given a small tip.

What are the Max fee and Gas limit?

When executing transactions on the blockchain network, users can specify the maximum extra fee they are willing to pay for this transaction. They can do so by modifying the Max fee and Gas limit.

Max fee is the Gas Price in the formula “Gas Fee = Gas Used (limit) * Gas ​​Price (per unit). It refers to the Gas rate that the user is willing to pay. As long as the Max fee set by the user exceeds the sum of the Base fee and the Priority fee, the transaction will be successful, and the excess difference will be returned to the user after the transaction is completed.

For example, if Alice wants to pay Bob an ETH, she sets the Max fee to 300 gwei. At this time, the base fee of Ethereum is 100 gwei, and Alice provides an additional 50 gwei as the priority fee, then:

1) 21000 * 300 gwei = 6300000 gwei = 0.0063 ETH

1.0063 ETH will be debited from Alice’s account.

2) 21000 * 100 gwei = 2100000 gwei = 0.0021 ETH

Ethereum will burn 0.0021 ETH token supply

3) 21000 * 50 gwei = 1050000 gwei = 0.00105 ETH

Miners will receive a tip of 0.00105 ETH

4) Bob will receive 1 ETH

5) 1.0063 ETH - 0.0021 ETH - 0.00105 ETH - 1 ETH = 0.00315 ETH

Alice will receive a refund of 0.00315 ETH in her account.

Gas limit is the Gas Used in the formula “Gas Fee = Gas Used (limit) Gas ​​Used Gas Price per unit”. It refers to the amount of Gas the user is willing to consume. Standard ETH transfers require 21,000 units of Gas, and more Gas will be used up by complex operations in smart contracts.

The Gas limit works similarly to the Max fee. The transaction will be done as long as the amount of gas exceeds the required amount. The excess balance will be returned to the user after the transaction is completed. If the gas limit is set too small, the transaction will still be executed but not completed. For example, a simple ETH transfer uses 21,000 units of Gas, but the user limits the Gas limit to 20,000 units. Miners will still consume Gas to perform work equivalent to 20,000 units of Gas, but this is not enough to complete the transfer, nor Any fees will be refunded to the user.

Why are Gas Fees so expensive?

If you have ever used Ethereum’s decentralized finance (DeFi) applications or purchased NFTs on platforms such as OpenSea, you will be familiar with Ethereum’s high Gas Fee. According to on-chain data statistics, from May 2021 to April 2022, the average Gas Fee per transaction on Ethereum is more than $20, and the highest is even close to $200.

Why is Ethereum’s Gas Fee so expensive? There are multiple reasons:

  1. Complex transactions and smart contracts consume more Gas

When Ethereum performs different operations, it requires different operands and the amount of stored data. Addition and subtraction instructions use less gas, multiplication consumes more gas, and division requires more operations, so more gas is used.

As the functions of the decentralized application Dapp grow increasingly complex, the number of operations performed by smart contracts also increases. Therefore, users need to pay more gas fees.

  1. Limited network bandwidth and Transactions Per Second

Similar to all computers, Ethereum is limited in the number of transactions per second it can process. Before upgrading to Ethereum 2.0, about 15 transactions can be processed in 1 second. Compared with the global credit card payment company VISA, which can easily handle more than 2,000 transactions in 1 second, the performance of Ethereum is rather poor. When the number of users increases, congestion occurs, and users have to tip miners more to have their transactions prioritized.

  1. The popularity of Ethereum

In addition to technical reasons, the popularity of Ethereum also contributes to the high Gas Fee. According to basic economic theory, when supply is constant, an increase in demand will lead to an increase in prices. In the first half of 2020, many novel projects were born in the field of decentralized finance, such as lending, flash loans, derivatives, liquidity mining, yield farming, insurance, etc. In 2021, the NFT market also rode the wave of the DeFi craze and many Play-to-Earn blockchain games came into being. Since many of them are built on Ethereum, the number of users has surged, and the Gas Fee has remained high.

(Gas Fee on Ethereum. Source: Statista)

  1. The rise in ETH price

Another reason for the high Gas Fee is that it is denominated in ETH. Comparing the average data in 2021 and 2019, not only the gas price on the chain has increased by 10 times, but the price of ETH has also increased by more than 10 times, which is equivalent to an increase of more than 100 times in Gas Fee when measured in US dollars. It’s not hard to see why Ethereum’s Gas Fee is widely considered ridiculously expensive.

How to reduce the Gas Fee?

Reducing Ethereum’s high Gas Fee has become an urgent task in the cryptocurrency space. Although gas fees cannot be completely cut when using the Ethereum blockchain, there are at least some ways to reduce the amount.

What users can do to reduce the Gas Fee:

  1. Choose a trading session with a lower Gas Fee

Although the Gas Fee of Ethereum is generally higher, the price is not the same at all times. Usually, the Gas Fee will be lower on weekends and higher on weekdays. Using Ethereum during unpopular times can reduce the Gas Fee that users need to pay.

(Source: ethereumprice.org)

  1. Set a maximum rate limit for the transaction

Before initiating a transaction, users can adjust the Max fee and Priority fee they are willing to pay to tell the blockchain how many gwei are the highest rate they are willing to pay. As long as the Max fee is set higher than the Base fee and a small tip is given to the miner, the transaction will be executed within the next few blocks. For transactions with low timeliness requirements, users can reduce the expenditure by reducing the Max fee. It should be noted that the Max fee should be adjusted within a reasonable range, otherwise the transaction may fail.

  1. Make good use of Gas Fee monitoring and simulated trading tools

Some online tools including Blocknative ETH Gas Estimator, ETH Gas Station, Cryptoneur Gas Fees Calculator, Tenderly, and DeFI Saver can provide users with real-time Gas Fee information of Ethereum, and some also allow users to conduct simulated transactions. Making good use of this type of tool can give users a better understanding of the cost of a transaction and help them find time slots with lower fees.

  1. Select applications that can reduce costs

There are already several applications on Ethereum that can help users reduce the Gas Fee for transactions. For example, Rook and Balancer will bundle multiple transactions and propose them together in order to share the gas cost. Some protocols also provide users with discounts on Gas Fees and subsidies to attract users.

However, ways for users to fundamentally reduce the high Gas Fee on Ethereum are limited. That’s why the development team has also made many technical improvements:

  1. Layer 2 expansion plan

Now several expansion schemes can be adopted by Ethereum Layer 2 to increase the throughput of the blockchain network and reduce the Gas Fee, namely Rollups, state channels, side chains, Plasma, Validium, and hybrid schemes. Different Layer 2 expansion schemes have their own advantages and disadvantages. From the figure below, we can see the difference between the current Layer 2 scheme and the Ethereum main network in terms of sending and transaction fees.

(Source: l2fees.info)

Among the different Layer 2 expansion schemes, Rollups technology seems to be one of the most promising. Rollups uses Ethereum as the base layer and combines its security and decentralization features. It aggregates multiple transactions from users before submitting them to reduce the Gas Fee paid for each transaction.

Rollups are further divided into Optimistic Rollups and Zero-Knowledge Rollups. You can refer to the article “What is Rollups?” on Gate Learn to obtain an in-depth analysis of Rollups technology.

  1. Application of sharding technology

The cause of the high Ethereum Gas Fee is that the slow transaction processing capacity cannot cope with a large number of user demands. Therefore, increasing the transaction speed of Ethereum will reduce the congestion and the Gas Fee. Sharding technology divides a single blockchain network into multiple sub-blockchains that are processed in parallel to disperse user traffic and increase transaction speed.

Before the upgrade, Ethereum had only 1 chain to process transactions. After using the sharding technology, it will be split into 64 shard chains for simultaneous processing. As a result, the throughput of the blockchain network can be greatly improved. Combined with Rollups’ expansion plan, Ethereum can reach nearly 100,000 transactions per second (in theory). You can refer to the article “What is sharding?“ on Gate Learn to gain an in-depth analysis of sharding technology.

(Source: Hsiao-wei Wang)

Decentralized ledger without gas fees

The Gas Fee mechanism enables Ethereum to operate efficiently and continuously and to coordinate limited resources (such as storage space and network bandwidth) on the blockchain network. The Gas Fee measure for Ethereum is efficient from the perspective of token economics. The usage of blockchain network services is determined by the supply and the demand of the free market and the gas price is dynamically adjusted accordingly. In this way, limited resources will not be misused and the problem of output not matching the cost is also solved. Many cryptocurrencies have also learned from Ethereum’s experience of using Gas Fees as a way to allocate resources.

However, not all cryptocurrency protocols adopt the Gas Fee mechanism, such as the well-known project, IOTA. There is a fundamental flaw in the Gas Fee model: the short-term resource supply of the blockchain network is inelastic. Therefore, when a large number of transactions suddenly flood in, the Gas Fee price will skyrocket. This is an extremely poor experience for many users who have transaction needs but are unwilling to bear high costs, and it is also an obstacle to increasing people’s awareness of blockchain technology.

The IOTA protocol cuts in from the perspective of producers and consumers. Thus, the short-term resource supply of the network can grow synchronously with the increase of users. As long as the number of resource producers exceeds the number of consumers at any time, there will be no shortage of supply and price and the subsequent price skyrocketing. Specifically, an asynchronous consensus mesh structure called the Tangle is applied.

As a type of Directed Acyclic Graph (DAG), the Tangle architecture can add transaction nodes from any direction. Users must verify two transactions before they propose a transaction. If more people use the Tangle network, the transaction will be faster and more secure, which overcomes the bottleneck of expansion caused by limited resource producers when the number of users of traditional blockchain networks increases. The design philosophy of IOTA is “there is no contradiction between the roles of the account user and the verifier”, and each user is also a verifier, completely changing the operation of traditional distributed ledgers.

(Source: Wikipedia#/media/File:Blockchain_vs_tangle_bottleneck.png))

In theory, the throughput of the blockchain network will increase if more people use IOTA for transactions. However, actually, the Tangle architecture still has limitations in its scalability due to factors such as hardware devices, network latency, and I/O read and write environments. Since the number of resource providers is always greater than the number of consumers, IOTA is one of the few cryptocurrency protocols with zero fees. However, a zero handling fee does not mean free. In order to access the services of the IOTA network, users must provide more services to others, and the cost will be reflected in doing social work, so it is a kind of “All for one, one for all” operation mode.

Conclusion

Gas Fee is a fee that users need to pay when executing transactions or smart contract codes on a blockchain. It is a usage fee for a blockchain service, usually priced in the native token assets of the blockchain network. Gas Fee is very important to maintain the normal operation of the blockchain network. It economically rewards contributors who provide value and punishes attackers who try to disrupt the network. The practice of paying for services can also effectively avoid resource abuse.

The pricing mechanism of the Gas Fee ensures that fees are charged in a fair way, and it also raises the threshold for malicious transactions, which can better maintain the security of the blockchain network. As different applications such as decentralized finance (DeFi), NFTs and blockchain games are growing increasingly popular, the huge increase in users also highlights the lack of scalability of blockchain networks (such as Ethereum) and the unbearable sky-high gas fee. Fair charging service does not mean that it is an appropriate charging service.

In light of this, the Ethereum team also announced that the upgrade of Ethereum 2.0 will be completed in multiple stages, from f proof-of-work to proof-of-stake. The upgrade of Ethereum can reduce the energy consumption of network nodes. The introduction of Rollups and sharding technology can greatly reduce transaction costs and relieve network congestion, so as to improve users’ benefits by making Gas Fees more affordable.

Recently, other protocols (like IOTA) have approached the issue of scalability from the perspective of producers and consumers. With the directed acyclic graph (DAG) network architecture called Tangle, users do not need to pay gas fees for using services, but instead, need to provide more services in exchange for resources. As long as the number of producers is always greater than the number of consumers, there will be no shortage of supply. This idea is interesting and novel, but time will tell whether it can be successfully promoted.

Автор: Piccolo
Перекладач: cedar
Рецензент(-и): Hugo、Edward、Ashely、Joyce
* Ця інформація не є фінансовою порадою чи будь-якою іншою рекомендацією, запропонованою чи схваленою Gate.io.
* Цю статтю заборонено відтворювати, передавати чи копіювати без посилання на Gate.io. Порушення є порушенням Закону про авторське право і може бути предметом судового розгляду.
Розпочати зараз
Зареєструйтеся та отримайте ваучер на
$100
!
Створити обліковий запис