Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is Gas/Gas Price/Gas Limit?

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

The main content of this article is to explain "what is Gas/Gas Price/Gas Limit". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what Gas/Gas Price/Gas Limit is.

Gas

Gas corresponds to the actual number of operation steps of the ethernet virtual machine (EVM) in a transaction (Transaction). The simpler the transaction, such as a simple Ethernet currency transfer transaction, the fewer steps are required for Gas. On the other hand, if you want to calculate some complex operations, the consumption of Gas will be large. So the greater the amount of computation required by EVM for the transaction you submit, the higher the Gas consumption required.

Gas Price

Gas Price is how much Eth you are willing to give for the Gas of a unit, usually in Gwei. So the higher the Gas Price, the more Eth will be paid for each step of the transaction.

You may be unfamiliar with the Gwei unit. Gwei actually means 10 ^-9 Eth, that is, 1 Gwei = 0.000000001 Eth. So, when you set Gas price = 20 Gwei, it means you are willing to pay 0.00000002 Eth for a single step.

Speaking of which, if you are smart, you will realize that the formula for calculating the handling fee of Ethernet Square is very simple:

Transaction fee (Tx Fee) = actual operating steps (Actual Gas Used) * single-step price (Gas Price)

For example, your transaction requires Ethernet Square to perform 50 steps to complete the operation, and suppose you set the Gas Price to 2 Gwei, then the handling fee for the whole transaction is 50 * 2 = 100 Gwei.

Gas Limit

Gas Limit is the upper limit of Gas available in a transaction, that is, the maximum number of steps that will be performed in your transaction. Because the complexity of the transaction varies, the exact Gas consumption will not be known until the transaction is completed, so you need to set an upper limit on the amount of Gas used for the transaction before you submit the transaction.

If the transaction you submitted has not been completed and the Gas consumption exceeds the Gas Limit you set, the deal will be cancelled and the fees already consumed will also be deducted-to reward miners for their hard work. If the transaction has been completed and the consumed Gas does not reach Gas Limit, then the transaction service fee will only be charged according to the actual consumed Gas. In other words, the maximum service charge that may be charged for a transaction is Gas Limit * Gas Price.

Finally, it is worth mentioning that the higher the Gas Price, the sooner the deal you submit will be accepted by the miners. But people are usually reluctant to pay more fees, so how much should Gas Price be set to ensure that transactions are confirmed on the regional chain within normal time (eg 10 mins)? This website can help you. At the time of writing this article, a 1 Gwei Gas Price ensures that the transaction is accepted in about 50 seconds.

At this point, I believe you have a deeper understanding of "what Gas/Gas Price/Gas Limit is", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report