How to understand Gas fees? Why do Ethereum users tolerate high Gas fees?

How to understand Gas fees? Why do Ethereum users tolerate high Gas fees?

What is Gas?

Gas is a unit of measurement that measures the amount of money required to perform specific operations on the Ethereum network.

Since each Ethereum transaction requires computing resources to execute, each transaction costs money. Gas refers to the fee required to successfully conduct a transaction in Ethereum.

Gas fees are paid in ETH. Gas prices are expressed in gwei, which is itself a denomination of ETH, with each gwei equal to 0.000000001 ETH (10 -9 ETH). For example, instead of saying your gas fee is 0.000000001 ETH, it is better to say your gas fee is 1 gwei. "Gwei" itself means "giga-wei", which is equal to 1,000,000,000 wei. Wei itself (named after Wei Dai, the creator of b-money) is the smallest unit of ETH. According to Tokenview on-chain data, the Ethereum gas fee was 44.59 gwei on March 6.

Before the London upgrade

The way Ethereum network transaction fees are calculated changed with the London upgrade in August 2021. Here’s how it used to work:

Assume Alice pays Bob 1 ETH. In this transaction, the Gas limit is 21,000 and the Gas Price is 200 gwei.

The total fee will be: Gaslimit (units) * GasPrice, which is 21,000 * 200 = 4,200,000 gwei or 0.0042 ETH. When Alice sends money, 1.0042 ETH will be deducted from Alice's account. Bob will receive 1.0000 ETH. The miner will receive 0.0042 ETH.

London Upgrade

The London upgrade was implemented on August 5, 2021, making transactions on Ethereum more predictable for users by completely overhauling Ethereum's transaction fee mechanism. The high-level benefits of this change include better transaction fee estimates, generally faster transaction packaging, and offsetting the issuance of ETH by burning a certain percentage of transaction fees. Starting with the London network upgrade, each block has a base fee, which is the minimum price per unit of Gas contained in the block, calculated by the network based on the demand for block space. Along with the base fee for transaction fees being burned, users are also expected to set a tip (priority fee) in their transactions. Tips compensate miners for executing and propagating user transactions in blocks, and are expected to be set automatically by most wallets.

The total transaction fee is calculated as follows: Gas limit (units) * (Base fee + Tip)

Assume Jordan wants to pay Taylor 1 ETH. In this transaction, the gas limit is 21,000 (units) and the base fee is 100 gwei. Jordan also includes a 10 gwei tip.

Based on the formula above, we can calculate this to be 21,000 * (100 + 10) = 2,310,000 gwei or 0.00231 ETH.

When Jordan sends money, 1.00231 ETH will be deducted from Jordan's account. Taylor will receive 1.0000 ETH. The miner receives a 0.00021 ETH tip. The 0.0021 ETH base fee will be burned.

In addition, Jordan can also set a maximum fee for the transaction (maxFeePerGas). The difference between the maximum fee and the actual fee will be returned to Jordan, that is, Return = max fee-(base fee+priority fee). Jordan can set the maximum amount paid when the transaction is executed without having to worry about the "exceeding" base fee paid when the transaction is executed being too high.

Block size:

Prior to the London upgrade, Ethereum had fixed-size blocks. During times of high network demand, these blocks ran at full capacity. As a result, users often had to wait for high demand to subside before being included in a block, which led to a poor user experience.

The London upgrade introduced variable-sized blocks to Ethereum. The target size of each block is 15 million Gas, but the size of blocks will increase or decrease based on network demand until the block cap is 30 million Gas (twice the target block size).

Through the process of tâtonnement, the protocol reaches an equilibrium block size of 15 million on average. This means that if the block size is larger than the target block, the protocol will increase the base fee of the next block. Similarly, if the block size is smaller than the target block, the protocol will also reduce the base fee. The amount of the adjustment of the base fee is proportional to the distance of the current block size from the target block.

Base fee

Each block has a base fee that serves as a minimum price. To be eligible for inclusion in a block, each Gas offer must be at least equal to the base fee. The base fee is calculated independently of the current block, but is determined by the previous block, making transaction fees more predictable for users. When a block is mined, this base fee is "burned" and removed from circulation.

The base fee is calculated through a formula that compares the previous block size (the amount of gas used by all transactions) to the target block size. If the target block size is exceeded, the base fee increases by up to 12.5% ​​per block. This exponential growth makes it economically unfeasible for the block size to remain high indefinitely.

Compared to London’s previous Gas auction market, this change in transaction fee mechanism makes fee predictions more reliable.

Based on the table above - creating a transaction on block 9, the wallet will let the user determine the maximum base fee added to the next block is: current base fee * 112.5% ​​or 202.7 gwei * 112.5% ​​= 228.1 gwei.

Equally important, we are unlikely to see scaling spikes across the board due to the rate at which basefees increase across blocks.

Priority fee (tips)

Prior to the London upgrade, miners would receive the total gas fee from any transaction within a block.

Along with the destruction of the new base fee, the London upgrade introduced a priority fee (tip) to incentivize miners to include a transaction in a block.

Without tips, miners would find it economically viable to mine empty blocks, since they would receive the same block reward. Under normal circumstances, small tips provide miners with minimal incentive to include transactions. For transactions to be prioritized, ahead of other transactions in the same block, higher tips will be required in an attempt to outpace competing transactions.

Max fee

To execute a transaction on the network, users can specify the maximum amount they are willing to pay for the transaction to be executed. This optional parameter is called maxFeePerGas. When a transaction is executed, the maximum fee must exceed the sum of the base fee and the tip. The sender of the transaction will be refunded the difference between the maximum fee and the sum of the base fee and the tip.

Calculating fees

One of the main benefits of the London upgrade is to improve the user experience when setting transaction fees. For wallets that support the upgrade, wallet providers will not explicitly state how much you are willing to pay to complete the transaction, but will automatically set the recommended transaction fee (base fee + priority fee) to reduce the complexity burden on users.

EIP-1559

EIP-1559, implemented in the London upgrade, makes the transaction fee mechanism more complex than the previous Gas price auction, but it has the advantage of making Gas fees more predictable, resulting in a more efficient transaction fee market.

Users can submit transactions with a maxFeePerGas corresponding to how much they are willing to pay to execute that transaction, knowing that they will not pay more Gas than the market price (baseFeePerGas), and that the extra fees, minus their tip, will be refunded.

Why is there a gas fee?

In short, Gas fees help keep the Ethereum network secure. By charging a fee for every operation performed on the network, we prevent malicious actors from spamming the network. To avoid accidental or hostile infinite loops or other wasteful operations in your code, each transaction needs to set a limit on the number of computational steps it can use to execute code. The fundamental unit of computation is "Gas".

Even though the transaction contains a cap, any Gas not used in the transaction will be returned to the user (the returned Gas is max fee - (base fee + tip)).

What is Gas Limit?

The Gas limit refers to the maximum amount of Gas you are willing to consume in a transaction. More complex transactions involving smart contracts require more computational work, so they require higher Gas limits than simple payments. A standard ETH transaction requires a Gas limit of 21,000 Gas. For example, if you set a Gas limit of 50,000 for a simple ETH transfer, the EVM will consume 21,000 and you will get the remaining 29,000. However, if too little Gas is specified, for example, a Gas limit of 20,000 for a simple ETH transfer, the EVM will consume 20,000 Gas when trying to complete the transaction, but the transaction will not be completed. The EVM then reverts any changes, but since the miner has already done work worth 20k Gas, that Gas is consumed.

Why are gas fees so high?

The high gas fee is due to the popularity of Ethereum. Performing any operation on Ethereum requires consuming gas, and the gas space of each block is limited. Fees include calculations, storage or manipulation of data, or transfer of tokens, all of which consume different amounts of gas.

As Dapp functionality becomes more complex, the number of operations performed by smart contracts is also growing, which means that each transaction will take up more space in the limited size block. If there is more demand, users must offer higher tips to try to outbid other users' transactions. Higher tips can make your transaction more likely to be included in the next block.

The Gas price alone does not determine how much we need to pay for a transaction. To calculate the transaction fee, we have to multiply the total amount of Gas consumed by the Gas price in gwei.

Initiatives to reduce gas costs

Ethereum’s scalability upgrades should finally solve some of the gas fee issues, which in turn will allow the platform to process thousands of transactions per second and scale globally. Layer 2 scaling is a major initiative to greatly improve gas costs, user experience, and scalability.

More about layer 2

The new Proof of Stake (PoS) model introduced on the beacon chain should reduce high power consumption and reliance on specialized hardware. The chain will allow the decentralized Ethereum network to agree and keep the network secure while limiting energy consumption by requiring financial commitments. Anyone with at least 32 ETH can stake them and become a validator, responsible for processing transactions, verifying blocks, and proposing new blocks to be added to the chain. Users with less than 32 ETH can join a staking pool.

Strategies to reduce gas costs

If you want to reduce the gas cost of ETH, you can set a tip to indicate the priority of your transaction. Miners will "work" and execute transactions that provide higher tips, because they will keep the tip you paid, and are less inclined to execute transactions with lower tips.

Original link:

https://ethereum.org/en/developers/docs/gas/


<<:  The third batch of digital RMB pilot cities will be unveiled soon | Industrial Blockchain Development Weekly

>>:  Token economics in music cannot be ignored

Recommend

What is the fortune of a woman with a mole between her eyebrows?

Moles are distributed all over the human body. Do...

A woman with a good fortune for her husband

When ancient emperors were choosing concubines, t...

Do people with crooked teeth have bad relationships?

In some cases, we will consider a person's po...

Facial features of people who do what they want

Sometimes, some people are really the type who do...

Is it good for a woman to have high cheekbones and a pointed chin?

Although each of us hopes to be beautiful, but in...

Moles on your feet reveal your fortune

Moles on your feet reveal your fortune From the p...

SEC's new toy "crypto money printing machine" fined $1.7 billion in 7 years

A new report shows that as of December 31, 2020, ...

What does a mole under the mouth mean?

In mole physiognomy, the moles on each person'...

Like to talk about other people's appearance

It is said that we should be careful when speakin...