Home > web3.0 > Ethereum transfer fees and transfer speed, can you save money by setting up Gas cleverly?

Ethereum transfer fees and transfer speed, can you save money by setting up Gas cleverly?

DDD
Release: 2024-03-06 13:44:59
forward
1074 people have browsed it

When transferring ETH or ERC-20 Token through the wallet, we know that this transfer requires a handling fee. So, how are the transfer fees calculated?

If "engraving" is performed at the same time as the transfer, do I need to charge a higher fee? Today, Dabai will talk to you about the Gas mechanism of Ethereum.

When transferring money in the Ethereum network, although we pay the final handling fee in ETH, in fact, ETH is not directly consumed within Ethereum, but Gas is consumed. The word "Gas" means "(gas) fuel" in English. Operations in the Ethereum network require the consumption of Gas, just like driving a car requires consumption of fuel.

So, how is the transaction fee (ETH) calculated? Let’s first take a look at a screenshot of Dabai’s transfer in the Ethereum network:


Ethereum transfer fees and transfer speed, can you save money by setting up Gas cleverly?##In Ethereum For transfers on the Fang network, the handling fee is calculated as follows:

Transaction fee (ETH) = unit price of Gas x quantity of Gas consumed

In Dabai’s transaction In the transaction, the unit price of Gas (Gas Price) is 5Gwei, which is 0.0000000005ETH (8 zeros after the decimal point). Here Dabai will introduce to you the unit of ETH. The smallest unit of ETH is Wei, but when talking about Ethereum Gas, Gwei is often used. The relationship between ETH, Gwei, and Wei is as follows:

1 ETH = 10^9 Gwei (9 0s) = 10^18 Wei (18 0s)

Know the unit price of Gas , let’s take a look at the amount of Gas consumed by Dabai’s transfer containing “engraving”: 24876. Therefore, according to the above formula, multiply the unit price by the quantity to get the handling fee spent by Dabai:

Handling fee = 0.0000000005ETH x 24876 = 0.00012438ETH

The car goes to the gas station to add fuel, The price of gas is basically fixed, but in the Ethereum network, the unit price of Gas can be set by yourself. However, it should be noted that the unit price of

Gas will affect the speed at which the transaction is packaged.

In other words, the higher the unit price of Gas you give, the more miners will prioritize packaging your transactions in order to maximize their own interests. The following figure shows the unit price of Gas and the required transaction packaging time in actual operations according to website statistics.

In the statistical chart on the left, we can see that

more than 70% of the gas transferred to the Ethereum network has a unit price between 4 and 20Gwei,

less than 1Gwei or greater than 50Gwei Transactions account for very little. In the statistical chart on the right, we can see that if the gas unit price given is 4Gwei, the average waiting time required for packaged transactions is 0.6 minutes; if it is 20Gwei, the average waiting time is 0.2 minutes.


Ethereum transfer fees and transfer speed, can you save money by setting up Gas cleverly?The commonly used imToken wallet provides 5 in the gas unit price setting. ~100Gwei, the wallet sets the minimum unit price to 5Gwei, ensuring that the transaction can be packaged within a reasonable time. Of course,
If you want to jump in the queue and be packaged by miners as soon as possible, you can also increase the unit price of Gas yourself.

After talking about the unit price of Gas, let’s talk about the amount of Gas consumed.

In the Ethereum network, each transfer, regardless of the amount, consumes a fixed amount of Gas, which is 21,000. If you add a note ("engraving"), additional Gas will be consumed.

Going back to Dabai's transaction, the total amount of Gas consumed by Dabai is 24876, which includes a fixed consumption amount of 21000 and a note of Gas consumption of 3876. Note: The amount of Gas that needs to be consumed is related to the length of the input content. The more content, the more Gas that needs to be consumed.

If you look carefully at the transfer screenshot of Dabai, you will find that there is a bracket after the amount of Gas spent by Dabai, 24876, which is 41.46%. What does this percentage mean? If you look at the screenshot carefully, you will find that there is a Gas Limit on it, the value is 60000, and its 41.46% is exactly 24876.

Gas Limit refers to the upper limit of the amount of Gas consumed by this operation. You can set this upper limit yourself. For example, Dabai set 60000, but in actual operation this upper limit was not reached, and only 41.46% was used. Most wallets will set this upper limit for you by default. For us ordinary users, we don’t need to consider this upper limit when making ordinary transfers.

The Ethereum network sets this upper limit just in case. If a malicious smart contract is encountered, the execution of the contract will consume unlimited fuel, which will cause the transaction party's ETH balance to be completely consumed (malicious The smart contract may be a program bug, such as the contract execution falling into an infinite loop).

If the Gas Limit is set too low, for example, if it is set to 10,000, the amount of Gas required for any transfer will be at least 21,000, which is far more than the Gas Limit you set, and the transfer will fail. In other words, Gas Limit will affect whether a transaction can succeed.

The above is the detailed content of Ethereum transfer fees and transfer speed, can you save money by setting up Gas cleverly?. For more information, please follow other related articles on the PHP Chinese website!

source:zhihu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template