Why did Ethereum gas fees suddenly drop significantly?
This article was published on Rhythm Blockbeats, author: 0x88.
Introduction: On April 25, data showed that Ethereum Gas fees dropped to around 50 gwei, a new low since 2021. Previously, due to continuously rising gas fees, on-chain transaction fees once approached 1500 gwei. Recently, Ethereum's gas fees plummeted, possibly related to Ethereum increasing the block Gas Limit. On April 22, Ethereum raised the block Gas Limit from about 12.5 million gwei to 15 million gwei, an increase of approximately 20%. So what factors affect Ethereum's gas fees? This article may provide you with the answers.
Note: This article was first published on September 23, 2020, and some of the data may be outdated. Please be aware that the data may have changed significantly by the time of this publication.
When Uniswap distributed funds to over 200,000 user addresses, many people might have been happy but thought to themselves, "This gas fee is too high."
That day was a memorable one in Ethereum's history, with suggested gas fees reaching as high as 1000 GWEI, the highest point at that time.
On that historic day, when everyone was claiming airdrops, many encountered issues regarding gas fees. The high gas fees were no longer the problem; the issue was that even the maximum suggested gas fee could not complete transactions within the planned time. Everyone's Metamask showed pending transactions, spinning in circles, which was quite frustrating.
Why can't you complete a transaction immediately even when using the default gas fee amount? This article will explain the Ethereum transaction fee mechanism in detail and the issues encountered when initiating transactions on Ethereum.
The Logic of Gas
This matter starts with Ethereum accounts.
In the Ethereum network, there are two types of accounts: Externally Owned Accounts (EOA) and Contract Accounts.
Externally Owned Accounts are the accounts used by users, controlled by the holders of private keys. Contract Accounts refer to smart contracts with application logic, controlled by contract code (often owned by the project team). When users interact with DeFi applications, they are using their accounts to interact with the smart contracts of DeFi projects.
Various accounts can interact freely; transfers can occur between wallets, and contracts can call each other. Each on-chain interaction consumes a certain amount of computational power, determined by the computational difficulty, and Gas is the unit of measurement for computational power. For example, addition is relatively simple and consumes 3 Gas, while division is more complex and consumes 5 Gas.
Each unit of Gas has a corresponding price, known as Gas Price, measured in Wei. Users need to purchase ETH to pay for gas fees. 1 ETH = 1e18 Wei, and the commonly seen unit GWei is 1e9 Wei. Typically, wallet software estimates the cost of the transaction the user is about to initiate based on historical Gas Prices.
To avoid centralization of full nodes, blockchain networks that pursue decentralized architecture strictly limit the capacity of each block. For example, Bitcoin's Block Size Limit and Ethereum's Block Gas Limit. At the time of writing for Rhythm Blockbeats, Ethereum's Block Gas Limit was approximately 12,000,000 Gas, which is the upper limit of total computational power for each block. A block is generated approximately every 15 seconds. When transaction demand exceeds block capacity, users need to compete for resources within each block to have their transactions confirmed on-chain as quickly as possible. At this point, users will bid for Gas, and miners will prioritize transactions with higher Gas Prices.
Typically, when users make transfers, they will also see an option to adjust the Gas Limit. Unlike the Block Gas Limit, the Gas Limit refers to the maximum amount of Gas a user is willing to use for a single transaction. Sometimes, there may be vulnerabilities within contracts, causing a transaction to enter an infinite loop of calculations. Without a Gas Limit, this transaction could consume all the ETH in the user's wallet. Miners usually charge fees based on the actual computational power consumed by the transaction (Gas Used by Transaction), and any remaining ETH within the Gas Limit will be returned to the user's account.
Thus, we can conclude that the amount of ETH consumed (Ether Cost) = Transaction Fee (Gas Fee/Transaction Fee) = Amount of Gas consumed by each transaction (Gas Used By Transaction) * Gas Price (Gas Price).
Having understood Ethereum's fee mechanism and account types, let's look at the common issues users encounter during transactions.
Pending Transactions / Speeding Up Transactions?
Whenever a user initiates a transaction, it is placed in a transaction pool (Mempool). As mentioned earlier, miners prioritize packaging transactions with the highest Gas Prices from the pool (due to miners' profit-seeking behavior). Therefore, the Gas Price set by the user determines the speed at which the transaction is packaged and executed. During network congestion, as Gas Prices soar, users' transactions may remain pending for a long time. To expedite pending transactions, users can choose to pay a higher Gas Price (understood as giving miners more rewards to achieve a "cut in line" effect).
How is speeding up a transaction done? To better understand the logic of speeding up transactions, we need to understand another parameter: Nonce. Each transaction initiated by an account has a sequential transaction number—Nonce, starting from 0. Each time a transfer is initiated, the Nonce value of that account increases by 1.
When a user wants to speed up a transaction, they can select the speed-up transaction option in their Ethereum wallet, which will require them to pay a higher Gas fee. Once the user agrees, it is equivalent to initiating a new transaction, and the new transaction has the same Nonce value as the pending transaction.
Due to Ethereum network regulations, Nonce values must be continuous and cannot be skipped, and the Nonce value for each transaction from the same address cannot be repeated. Therefore, miners will package the newly generated transaction, and after the new transaction is confirmed, the previously lower Gas Price transaction will be discarded.
If the user does not want to speed up 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 for canceling a transaction is the same as for speeding it up; the user initiates a transaction with a higher Gas Price but with the same Nonce as the pending transaction, but the transaction amount is set to 0. Thus, essentially, the cost of canceling a transaction is the same as the cost of speeding it up.
It is important to note that until the pending transaction is confirmed, subsequent transactions will need to wait in line. Therefore, users should avoid initiating multiple transactions due to long wait times.
Transaction Failure
Rhythm Blockbeats has found that the most common reason for transaction failure is running out of gas (Out of Gas). This means that the computational power required for the transaction exceeded the Gas Limit set by the user. In such cases, the transaction status will show as failed, indicating that gas has been exhausted, and the gas fees paid will not be refunded.
Some users may feel this is unfair, but essentially, miners have already done work in calculations; they just ran out of gas halfway through, so they can only abandon the work. However, the previous work needs to be compensated, so it is understandable that the gas fees paid are not refunded. In such situations, users can only initiate the transaction again and increase the Gas Limit for that transaction.
Another reason for transaction failure occurs when a user initiates a transaction to transfer funds to a smart contract, but some error prevents the contract from executing, resulting in a Bad Instruction.
For example, when users participate in crowdfunding activities, the following situations may occur:
Quota is full;
Or the user is not on the whitelist;
Or the user has over-subscribed tokens, etc.
In this case, the Gas Limit set by the user will be completely consumed, ultimately leading to transaction failure.
However, after the Ethereum Byzantine hard fork, a new operator Reverted (EIP-140) was added. When an error occurs in the contract causing the transaction to fail, the transaction will not consume all the gas set by the Gas Limit; the contract will stop executing and return the remaining gas fees while informing the user of the error reason.
Of course, if the amount of ETH in the user's wallet is insufficient to pay for the gas fees, the transaction will also be deemed a failure.
When there are no hot topics, the Ethereum network is peaceful, and all transfer costs, including time and amount, are manageable. However, when a trend arises, users in the network will encounter various issues, and the logic of gas fees is the biggest obstacle for newcomers using wallets.
Basically, this article covers all the issues related to gas fees. On-chain transactions are not complicated; to put it simply, if there are problems with any operation, adding more funds can resolve it.
Currently, it seems that the wave of liquidity mining on Ethereum has come to a temporary halt. This movement, besides creating a bubble, has also allowed more users to become accustomed to using wallets, which have finally become a high-frequency tool.
The issues arising from on-chain transactions are also providing space for wallet optimization, and services like "one-click speed up" and "one-click cancel" may increasingly be seen in more wallets.