ETH以太坊中的Gas究竟是什么?

资讯 2024-06-20 阅读:30 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

Gas翻译为中文是燃料/汽油的意思。在以太坊(或其他网络),为了执行特定的操作(比如发送代币、存储、兑换代币)需要消耗一定的燃料,这个燃料我们称之为Gas。这就好比汽车要跑,就需要消耗汽油。在以太坊,要进行各种交互,就需要消耗Gas。举个例子:

Gas translates to Chinese as fuel/fuel. In Etheria (or other networks), certain fuel is required to perform certain operations (e.g. sending, storing, converting, etc.), which we call Gas. This is like running a car, consuming gasoline. In Etheria, for all kinds of interactions, it is necessary to consume Gas.

假设开车从A地到B地需要消耗10升汽油,每升的价格8元,那么,从A到B需要消耗的汽油费用:10*8=80(元)。

Assuming that driving from A to B would cost 10 litres of petrol at a price of $8 per litre, the cost of petrol from A to B would be 10*8 = 80 yuan.

同样,在以太坊网络,假设执行发送代币这个操作,需要消耗Gas的数量是21000个单位,每个单位Gas价格是100gwei。则执行这笔操需要支付的费用:21000*100=2100000gwei。

Similarly, on the Etheria network, it is assumed that the number of units that need to consume Gas is 21,000 and the price per unit is 100 gwei. The cost of carrying out this exercise is 21,000*100 = 210,000,000 gwei.

为什么需要Gas

Why do you need Gas?

我们都知道,在web2当中最重要的一个策略就是免费,来吸引流量实现变现。那么web3中的以太坊为什么不这么做呢?

We all know that one of the most important strategies in Web2 is free to attract the flow to make it real. So why not Etheria in Web3 do that?

收取gas费除了打赏奖励矿工等激励性质的作用之外,另一个作用就是防止恶意的攻击,假设没有gas费的设置,攻击者就可以发布无数死循环的合约,然后不断通过发送交易让节点运行,劫持全网的大量算力使得系统瘫痪。通过规定gas消耗量,以避免一些代码恶意的无限循环,导致资源浪费。当所有的gas消耗殆尽,就停止继续运转,好比汽车的汽油耗尽,车就停下来不走了,这就不至于无效者继续占坑。

In addition to the role of incentives such as reward for miners, the collection of gas fees has the effect of preventing malicious attacks, assuming that without gas fees, the attackers can issue numerous life-cycle contracts and continue to block the system by sending deals to allow nodes to operate, hijacking the entire network with a great deal of arithmetic. The waste of resources is caused by fixing gas consumption to avoid the vicious circle of some codes. When all gas is depleted, it stops functioning, as if the car was running out of gas, so that the car does not stop, so that the invalids do not continue to take advantage of the pit.

Gas Limit

什么是Gas Limit

What's Gas Limited?

在开头例子中,要计算从A地跑到B地汽油花了多少钱,除了要知道汽油价格(多少钱1升),还需要知道消耗的汽油量(用了多少升)。

In the initial example, the amount of gasoline spent from Land A to Ground B was calculated and, in addition to the price of petrol (how much 1 litre) it needed to be known how much petrol was consumed (how much litres were used).

同样,在以太坊网络,要计算某笔操作的成本(手续费),除了要知道Gas的价格,还要知道消耗的Gas的数量。

Similarly, in the Etheria network, the cost of a particular operation (the handling fee) is calculated by knowing, in addition to the price of Gas, the amount of Gas consumed.

Gas数量要消耗多少,由合约创建者设定,不同合约、不同类型的操作,消耗的gas数量不尽相同,操作越复杂需要消耗的gas越多,所以很难预先估计Ga的消耗量,为此采取的办法是,给定一个比实际消耗更高的限值,即Gas Limit,如果实际未消耗这么多,剩余部分将退回用户。

The extent to which the number of Gas is consumed is set by the contract creators, different contracts, different types of operations, different quantities of Gas, and the greater the complexity of the operation, the greater the consumption of Gas, making it difficult to estimate in advance the consumption of Ga by giving a higher limit than the actual consumption, that is, Gas Limit, and if this is not actually consumed, the remainder will be returned to the user.

在计算消耗的Gas数量时,钱包提供商比如metamask往往直接给出Gas Limit,如果实际消耗小于Gas Limit,剩余的返还。如果实际消耗超过Gas Limit,交易无法完成。

In calculating the amount of Gas consumed, wallet providers, such as Metamask, often give Gas Limit directly, if the actual consumption is less than Gas Limit, the remaining return. If the actual consumption exceeds Gas Limit, the transaction cannot be completed.

假设一笔以太坊网络转账需要消耗的Gas数量为21000,Gas Limit设置为50000,而实际只消耗21000,那么剩下的29000将自动返还。但如果实际消耗需要51000,而你只设置为50000,那么这笔交易将不会完成,消耗的50000也不会退回。

Assuming that the number of gasses to be consumed by the Taiwan network transfers is 21,000, and that Gas Limited is set at 50,000, while only 21,000 is actually spent, the remaining 29,000 will be returned automatically. If the actual consumption is 51,000, and you are set at 50,000, then the transaction will not be completed, and the 50,000 will not be returned.

所以,如果试图通过减小Gas Limit数值达到减少手续费的目的,可能会适得其反。不仅交易可能不成功,手续费照样扣。

Therefore, it may be counterproductive to attempt to reduce fees by reducing the value of Gas Limit. Not only may the transaction be unsuccessful, but the fees are deducted.

Gas Limit如何确定?

How can Gas Limited be sure?

Gas Limit的数值一般是钱包提供商默认自动给出的,通常不需要我们手动修改或者调整。

Gas Limit's values are generally given automatically by the wallet provider by default and usually do not require manual modifications or adjustments.

Gas price

什么是Gas price

What's Gas Price

Gas price,是指 Gas 的价格/单价,通常用Gwei来表示。

Gas price, which refers to the price/unit price of Gas, is usually expressed in Gwei.

Gas price如何确定

How does Gas Price determine

在2021年8月5日伦敦升级实施后,Gas price变成包含两部分的费用:基本费(base fee)和小费(Max priority fee)。

Following the implementation of the London upgrade on 5 August 2021, Gas Price became a two-part cost: base feed and tip.

「1.Base fee」

即基本费。每个区块都有一个作为底价的基本费,为了有资格被包含在一个区块中,Gas价格必须大于等于基本费。基本费用的确定方法,这里不展开,反正用户自己修改不了,由以太坊本身决定。

That is, the base fee. Each block has a base price, which, in order to be eligible for inclusion in a block, Gas must be greater than or equal to the base fee. The basic cost is determined in such a way as not to be started here, and the user itself cannot change it.

「2.Max priority fee」

即小费的意思。在滴滴打车的时候,遇到高峰时段,如果加10元、20元小费,可能你会优先叫到车。在以太坊网络Gas费的设计机制中,同样适用这个道理。你给小费,就可能优先成交。这里需要注意,基本费是根据网络拥堵情况实时变动的,可以通过网站查询基本费,而小费可以自己调整,一般调高不调低。

That means tipping. When you hit a drop-by, if you add $10 and $20, you might call the car first. The same thing applies in the design mechanism for the Taiwan network Gas fee. You give tips, you may pay them first. Here, it needs to be noted that the base fee changes in real time, depending on the congestion, and can search the base fee through the website, while the tip can be adjusted by itself, generally up and down.

「3.Max fee」

即每单位Gas的最高费用。最高费用是你愿意为每单位Gas支付的绝对最高金额,以使你的交易得到确认。在大多数情况下,你的实际交易费用将低于你预先指定的最高费用,你交易的最低Gas价格是当前的基本费用。然而,如果在你交易尚未完成时,基准费用增加了呢?那么,你的交易就有可能被卡住,或失败或被放弃。因此,为了在EIP-1559下实现可预测的交易结算,目前认为最好的做法是设置一个预期基本费用增加的最高费用。

That is, the maximum cost per unit Gas. The maximum cost is the absolute maximum that you are willing to pay for each unit Gas so that your transaction can be confirmed. In most cases, the actual transaction cost will be lower than the maximum fee you set in advance, and the lowest price for your transaction will be the current basic cost. But, if the base cost increases when your transaction is not completed, then your transaction may be stuck or lost or abandoned. So, in order to achieve a predictable settlement of the transaction under EIP-1559, it is now considered preferable to set a maximum cost of the anticipated basic cost increase.

上图是真实的交易费用。

The figure above is a true transaction cost.

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
  • 0.00015693个比特币等于多少人民币/美金

    0.00015693个比特币等于多少人民币/美金
    0.000 15693比特币等于多少人民币?根据比特币对人民币的最新汇率,0.000 15693比特币等于10.6 1678529美元/76.86554996人民币。比特币(BTC)【比特币价格翻倍】美元(USDT)人民币(CNY)0.000/克洛克-0/5693【数字货币矿机】10.6 167852976.8655254996比特币对人民币的最新汇率为:489,807.72 CNY(1比特币= 489,807.72人民币)(1美元=7.24人民币)(0.00015693 U...
  • 币圈院士:5.20比特币(BTC)以太坊(ETH)行情分析

    币圈院士:5.20比特币(BTC)以太坊(ETH)行情分析
    利空出尽?华尔街多头坚信美股将摆脱泥潭 经济衰退风险被夸大A lot of people on Wall Street believe that beauty will escape the quagmire; the risk of recession is exaggerated. 从目前美国经济的情况加上美股先有的走势来判断,确信通胀已经或即将见顶,这为价格压力回落铺平了道路,这最终将使美联储得以放缓...
  • 2000年美国GDP占世界的304%,中国GDP仅占35%,现在呢?

    2000年美国GDP占世界的304%,中国GDP仅占35%,现在呢?
    GDP作为全球公认的实力基准,就像是一个大国实力的代言人,它是布雷顿森林体系下全球团结的声音。它不仅仅是数字的累积,更是大国综合实力的人格化,默默诉说着每个国家的辉煌与荣耀。虽然GDP不是衡量一个国家综合实力的唯一标准,但无疑是最关键的指标之一。作为一面镜子,它反映了国家的经济实力和发展水平,是国家综合实力的重要体现,不容忽视。2000年,中国GDP迈过/克洛克-0/万亿美元的重要门槛,达到/克洛克-0/。2/克洛克-0/万亿美元(折合人民币7。7万亿元)。然而,在全球经济的...
标签列表