Preface: On April 25, data showed that Ethereum Gas costs fell by around 50Gwei, to a new low since 2021. Previously, the on-chain handling fee approached 1500GWEI due to the constant increase in gas charges. Ethereum has recently seen a sharp drop in its gas bill, which may have something to do with Ethereum's upgrade of the gas Limit. On April 22, Ethereum raised the block Gas Limit from about 12.5 million Gwei to 15 million Gwei, an increase of about 20%. So what are the factors that affect Ethereum's Gas bill? This article may give you the answer.
注:本文首次发表于2020年9月23日,其中部分数据均为当时数据, 阅读时请注意截止今日发表时数据或有较大变动。
"That's too much gas," may have been the thought of a lot of people as Uniswap distributed money to more than 200,000 user addresses.
It was a memorable day in the history of Ethereum, as the maximum recommended gas reached 1000 Gwei, which was the highest in history at the time.
In the morning of witnessing history and nationwide airspace voting, many people have encountered the problem of gas fee. The high gas fee is no longer a problem, but the problem is that the maximum value of the gas fee paid to the wallet can not be closed within the planned time. Everyone on the MetaMask is "Pending". It goes round and round and round so annoying.
Why are you using the default amount of gas fee, but you still can't transact immediately? This article will explain in detail the Ethereum transaction rate mechanism and the problems encountered in initiating transactions on Ethereum.
It starts with the Ethereum account.
There are two types of accounts in the Ethereum network, external Owned accounts and Contract accounts.
External accounts are the accounts used by users, which are controlled by the private key holder. A contract account is a smart contract with application logic that is controlled by the contract code (often owned by the project party). When users use the Defi app, they are using their account to interact with the Defi smart contract.
Accounts can interact with each other at will, wallets can transfer money, and contracts can call each other. Each on-chain interaction needs to consume a certain amount of calculation. The amount of calculation is determined by the difficulty of calculation, and GAS is the unit of measurement of calculation. For example, the addition operation is relatively simple and requires 3 Gas, while the division operation is relatively complex and requires 5 Gas.
Each unit of Gas has its own price, known as the Gas price (Gas Price), while the Gas Price is in Wei. Users need to buy ETH to pay for Gas. 1 ETH=1e18 Wei, whereas we usually see a unit of Gwei of 1e9Wei. Typically, the wallet software will use the historical Gas Price to estimate the cost of the transaction that the user is about to initiate.
In order to avoid centralization of all nodes, a blockchain that seeks to decentralize its architecture severely limits the capacity of each block. For example, Bitcoin's Block Size Limit and Ethereum's Block Gas Limit. At the time of the Rhythm BlockBeats article, the Block Gas Limit for each Ethereum Block was about 12,000,000 Gas, which is the maximum amount of computation per Block. On average, one block is produced every 15 seconds. When the demand for transactions exceeds the block capacity, users need to compete for resources in each block in order to confirm their transactions on the chain as soon as possible. At this point, the user bids on the Gas, and the miner will prioritize the transaction with the high Gas Price into the block.

Often users will also see an increased option to adjust the Gas Limit in their wallet when making a transfer. Unlike a Block Gas Limit, a Gas Limit is an upper Limit on the amount of Gas a user can accept for a transaction. A deal is calculated in an endless loop because there may sometimes be a loophole in the contract. Without the Gas Limit, the transaction will consume all the ETH in the user's wallet. Miners are charged a fee based on the amount of Gas Used by Transaction, and the remaining ETH in the Gas Limit is returned to the user's account.
So we can say, The amount of ETH consumed (Ether Cost)= Gas Fee/Transaction Fee = amount of Gas consumed per Transaction (Gas Used By Transaction) * Gas price (Gas) Price).
With an understanding of Ethereum's handling fee mechanism and account types, let's take a look at some of the problems users often encounter when making transactions.
Each time a user initiates a transaction, the transaction is placed in a trade pool. As mentioned above, the miners give priority to the deal with the highest Gas Price in the package pool (the miners' drive for profitability). So the Gas Price set by the user determines how quickly the transaction can be packaged and executed. When the network is congested, customers can have their transactions waiting to be confirmed for long periods of time as Gas prices soar. In order to expedite the pending transaction, users can choose to pay more Gas Price to expedite the transaction.
How does accelerated trading work? To understand the logic of accelerating transactions in more detail, we need to understand another parameter: Nonce. Each transaction issued by an account has a sequential transaction number, a Nonce, starting at 0 and increasing the Nonce value of that account by 1 for each transfer.

When a user wants to speed up a transaction, in the Ethereum wallet, the user can choose the option to speed up a transaction, and they will be asked to pay higher Gas charges. After agreeing to the option, the user initiates a new transaction with the same Nonce value as the transaction to be confirmed.
Since the Ethereum network rules that the Nonce value is continuous and cannot be jumped, and the Nonce value for each transaction at the same address cannot be repeated, the miner will package the newly generated transaction, and after the new transaction has been packaged and confirmed, the previous transaction at the lower Gas Price will be scrapped.
If the user does not want to accelerate the transaction, the user can choose to cancel the transaction at any time as long as the transaction remains unpackaged in the trading pool. The logic for canceling a transaction is the same as for accelerating a transaction, where 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 zero, so essentially the cost of canceling the transaction is the same as the cost of accelerating the transaction.
It should be noted that pending transactions need to be queued up before they are confirmed to be completed, so users should not initiate multiple transactions due to long waiting time.
Transaction Fail
According to Blockbeats, the most common cause of trading failure is running Out of Gas. In other words, the amount of computation for the transaction exceeds the Gas Limit set by the user. Normally in this case, the transaction status will be displayed as failed, with an indication that the Gas has been exhausted and that the Gas paid will not be refunded.
Some users may think this is unfair, but in essence the miners are already doing their work and are not enough to calculate half of the Gas, so the miners have to give up and continue working, but they have to be "paid" for their previous work, so it is probably understandable that they will not be refunded for their previous Gas. In this case, the user can only initiate a new transaction and increase the Gas Limit for this transaction.
Another case where a transaction fails is when a user initiates a transaction transfer to a smart contract, but some error prevents the contract from being executed, and the transaction returns Bad Instruction.
For example, when a user participates in something like a crowdfunding campaign, the following things might happen:
The quota is full;
Or the user is not whitelisted;
Or users oversubscribed for tokens.
At this point, the Gas Limit set by the user will be used up, and the transaction will fail.
After the Byzantine hard fork, Ethereum has added a new operator, Reverted (EIP-140). When a transaction fails due to an error in the contract, the transaction will not exhaust all the Gas set by the Gas Limit, the contract will stop execution and the remaining Gas fee will be refunded, and the user will be informed 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 bill, the transaction is also judged to have failed.
When there is no hot spot, the Ethereum network is peaceful and all the transfer costs, including time and amount, are controllable. However, when the outlet comes, people will encounter various problems in the network. The logic of gas fee is the biggest obstacle for newcomers to use the wallet.
Basically, this article covers all the problems encountered in GAS fee. On-chain transaction is not complicated. Simply put, if there is a problem in all operations, you can solve it by adding money.
The movement now seems to have put an end to the flow mining craze on Ethereum, creating a bubble and getting more users to get used to wallets, which have finally become a tool of high frequency.
The problems with on-chain transactions also provide space for wallet optimization, and services such as "one-click acceleration" and "one-click cancellation" for newcomers may be seen in more and more wallets.
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia