Preface: On April 25, data showed that Ethereum's gas fee dropped by about 50gwei, the lowest since 2021. Previously, due to the continuous increase in gas fees, the on-chain handling fee was close to 1500gwei. The recent sharp drop in Ethereum's gas fee may be related to Ethereum's increase in block gas limit. On April 22, Ethereum increased the block gas limit from about 12.5 million Gwei to 15 million Gwei, an increase of about 20%. So what factors will affect Ethereum's gas fee? This article may give you the answer. Note: This article was first published on September 23, 2020. Some of the data in it are current at the time. Please note that the data may have changed significantly as of today's publication. Written by: 0x88, BlockBeatsWhen Uniswap distributed money to more than 200,000 user addresses, many people were probably thinking, "This gas fee is too high." That day was a memorable day in the history of Ethereum, with the gas recommendation reaching a maximum of 1000 GWEI, which was the highest point in history at the time. On the morning of the day when we witnessed history and everyone received the airdrop, many people encountered problems with gas fees. The high gas fee was no longer a problem. The problem was that even if the gas fee was paid to the maximum recommended by the wallet, the transaction could not be completed within the planned time. Everyone's Metamask showed pending, which was annoying. Why can't you trade instantly even though you use the default gas fee amount? This article will explain in detail the Ethereum transaction fee mechanism and the problems you will encounter when initiating transactions on Ethereum. Gas LogicThis matter starts with the Ethereum account. There are two types of accounts in the Ethereum network, Externally Owned Account and Contract Account. External accounts refer to accounts used by users and are controlled by private key holders. Contract accounts refer to smart contracts with application logic, which are controlled by contract code (often owned by the project party). When users use DeFi applications, they are using their own accounts to interact with the smart contracts of DeFi projects. Accounts of all kinds can interact with each other at will, wallets can transfer money, and contracts can call each other. Each on-chain interaction requires a certain amount of computing power, which is determined by the difficulty of the calculation, and Gas is the unit of measurement for the amount of computing power. For example, addition is relatively simple and requires 3 Gas, while division is relatively complex and requires 5 Gas. Each unit of Gas has a corresponding price, which is the Gas Price, and the Gas Price is in Wei. Users need to buy ETH to pay for the Gas fee. 1 ETH = 1e18 Wei, and the unit GWei we usually see is 1e9 Wei. Usually, the wallet software will estimate the cost of the transaction that the user is about to initiate through the historical Gas Price. In order to avoid the centralization of all nodes, blockchains that pursue a decentralized architecture will strictly limit the capacity of each single block. For example, Bitcoin's Block Size Limit and Ethereum's Block Gas Limit. At the time of writing this article, the Block Gas Limit of each single block in Ethereum was about 12,000,000 Gas, which is the upper limit of the total computational capacity of each block. On average, one block is produced every 15 seconds. When transaction demand exceeds the block capacity, users need to compete for resources in each block in order to have their transactions confirmed on the chain as quickly as possible. At this time, users will bid for Gas, and miners will prioritize transactions with high Gas Prices into the block. Usually, when users transfer money, they will see that the wallet will increase the option to adjust the Gas Limit. Different from the Block Gas Limit, the Gas Limit refers to the upper limit of the Gas usage that the user can accept for a transaction. Because there may be loopholes in the contract sometimes, a transaction will be calculated in an endless loop. If there is no Gas Limit, the transaction will consume all the ETH in the user's wallet. The fees usually charged by miners are settled according to the actual amount of calculation consumed when executing the transaction (Gas Used by Transaction), and the remaining ETH within the Gas Limit will be returned to the user's account. So we can conclude that the amount of ETH consumed (Ether Cost) = transaction fee (Gas Fee/Transaction Fee) = the amount of Gas consumed in each transaction (Gas Used By Transaction) * Gas price (Gas Price). Now that we understand Ethereum’s fee mechanism and account types, let’s look at the problems that users often encounter when trading. Pending transactions/accelerated transactions?Whenever a user initiates a transaction, the transaction will be placed in a transaction pool (Mempool). As mentioned above, miners will prioritize packaging transactions with the highest Gas Price in the pool (miners' profit-seeking). Therefore, the Gas Price set by the user determines the speed at which the transaction is packaged and executed. When the network is congested, due to the soaring Gas Price, the user's transaction may be in a pending confirmation state for a long time. In order to send the pending transaction as soon as possible, the user can choose to pay more Gas Price to speed up the transaction (Rhythm Note: It is understood as giving miners more rewards to achieve the purpose of cutting in line). How does accelerated transaction work? In order to understand the logic of accelerated transaction in more detail, we need to understand another parameter: Nonce. Each transaction sent by an account will have a sequentially arranged transaction number - Nonce, starting from 0. Every time a transfer is initiated, the Nonce value of the account will increase by 1. When a user wants to speed up a transaction, in the Ethereum wallet, the user can select the accelerated transaction option, in which case the user will be required to pay a higher Gas fee. After the user agrees, it is equivalent to initiating a new transaction, and the new transaction has the same Nonce value as the transaction to be confirmed. Due to the Ethereum network regulations, the Nonce value is continuous and cannot jump, and the Nonce value of each transaction with the same address cannot be repeated, so miners will package the newly generated transactions. After the new transactions are packaged and confirmed, the previous transactions with lower Gas Prices will be discarded. If the user does not want to accelerate the transaction, as long as the transaction is still in the transaction pool and has not been packaged, the user can choose to cancel the transaction at any time. The logic of canceling the transaction is the same as accelerating the transaction. The user initiates a transaction with a higher Gas Price but the same Nonce as the transaction to be confirmed, but the transaction amount becomes 0, so in essence, the cost of canceling the transaction is the same as the cost of accelerating the transaction. It should be noted that before the pending transaction is confirmed, all subsequent transactions will have to wait in line, so users should not repeatedly initiate multiple transactions due to long waiting time. Transaction failed (Fail) BlockBeats found that the most common reason for transaction failure is that the transaction gas has been exhausted (Out of Gas). In other words, the calculation amount of this transaction exceeds the Gas Limit set by the user. Generally in this case, the transaction status will be displayed as failed, and it will be prompted that the Gas has been exhausted, and the paid Gas will not be refunded. Some users may think this is unfair, but in essence, miners are already doing work calculations, but they run out of Gas halfway through, so they can only give up and continue working. However, the previous work needs to be paid, so it is probably understandable that the Gas fee paid previously is not refunded. In this case, users can only initiate a new transaction and increase the Gas Limit of this transaction. Another case of transaction failure is when a user initiates a transaction transfer to a smart contract, but some errors prevent the contract from being executed, and the transaction returns a Bad Instruction. For example, when users participate in a crowdfunding campaign, the following may happen: The quota is full; Or the user is not whitelisted; Or the user oversubscribes for tokens, etc. At this point, the Gas Limit set by the user will be completely used up, eventually leading to transaction failure. However, after the Ethereum Byzantium hard fork, a new operator Reverted (EIP-140) was added. When an error occurs in the contract and causes a transaction to fail, the transaction will not consume all the Gas set by the Gas Limit, and the contract will stop executing and refund the remaining Gas fee, while informing the user of the cause of the error. Of course, if the amount of ETH in the user's wallet is not enough to pay the Gas fee, the transaction will be judged as failed. When there are no hot spots, the Ethereum network is peaceful, and all transfer costs, including time and amount, are controllable. But when the trend comes, everyone will encounter various problems in the network. The logic of gas fees is the biggest obstacle for newcomers to use wallets. Basically, this article covers all the problems you may encounter with gas fees. On-chain transactions are not complicated. To put it simply, if there is any problem with the operation, you can just add money to solve it. From the current perspective, the craze for liquidity mining on Ethereum has come to a temporary end. In addition to creating a bubble, this movement has also made more users accustomed to the use of wallets, and wallets have finally become a high-frequency used tool. The problems that occur in on-chain transactions are actually providing space for wallet optimization. Services such as “one-click acceleration” and “one-click cancellation” for newcomers may be seen in more and more wallets. |
<<: What is the value of Chia, the rising star in storage mining?
>>: The market continues to consolidate, and the market is in a wait-and-see mood
A person's fate is not fixed. Many people oft...
Bitcoin has been fluctuating a lot recently, whic...
Sina Technology News on the morning of February 2...
For a woman, being a jinx to her husband does not...
A good face can bring blessings to people, so is a...
The thickness of eyebrows has a great influence o...
What kind of man's face is worthy of entrusti...
On December 20, the "2019 Digital Mining Sum...
In modern society, women are becoming more and mo...
How to identify people with wisdom? As the saying...
Are there people around you who work hard all day...
I believe that people with straight eyebrows will...
When it comes to information about facial feature...
Physiognomy not only includes face and palm readi...
Everyone is likely to cheat, and everything that ...