为什么我钱包里还有ETH,但交易就是确认不了?

资讯 2024-06-21 阅读:79 评论:0
在 Uniswap 给 20 多万个用户地址撒钱的时候,也许不少人在开心之余心里想的都是,「这 gas 费也太高了。」When Uniswap spreads money to more than...
美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

APP下载   官网地址

在 Uniswap 给 20 多万个用户地址撒钱的时候,也许不少人在开心之余心里想的都是,「这 gas 费也太高了。」

When Uniswap spreads money to more than 200,000 user addresses, maybe a lot of people think, "This gas is too expensive."

当天是以太坊历史上值得纪念的一天,gas 建议最高达到了 1000 GWEI,这是历史最高点。

The day was a memorable day in Taiku's history, and Gas suggested a maximum of 1,000 GWEIs, the highest point in history.

在见证历史、全民领空投的当天上午,不少人都遇到了关于 gas 费的问题,gas 费贵已经不是问题了,问题是 gas 费交到钱包建议的最大值也不能在计划时间内成交。大家 Metamask 上显示都是 pending,一圈一圈转得让人心烦。

On the morning of the historic, popular air campaign, a lot of people were confronted with the question of gas fees. Gas fees were no longer a problem. The problem was that the maximum value of gas fees to the wallet proposal could not be paid within the planned time frame.

为什么你使用了默认的 gas 费金额,却依然不能即时交易?。此文将详细讲解以太坊交易费率机制以及在以太坊上发起交易会遇到的问题。

Why do you use the default gas fee, but still cannot be traded instantaneously?

Gas 的逻辑

Gas Logical

这个事要先从以太坊账户讲起。

This has to start with the Etheraya account.

以太坊网络中有两类账户,外部账户(Externally Owned Account)以及合约账户 (Contract Account)。

There are two types of accounts, the External Account and the Contract Account.

外部账户是指用户们所使用的账户,由私钥持有者所控制。合约账户是指带有应用逻辑的智能合约,由合约代码所控制(往往是项目方所有)。用户们在使用 DeFi 应用时,就是在用自己的账户与 DeFi 项目的智能合约进行交互。

External accounts are accounts used by users, controlled by private key holders. Contract accounts are smart contracts with applied logic, controlled by contract codes (often owned by project parties). When users use the DeFi application, they interact with the DeFi project smart contracts using their own accounts.

各类账户之间可以随意进行交互,钱包间可以进行转账,合约间也可以相互调用。每一次链上交互都需要消耗一定的计算量,计算量消耗的大小由计算难度所决定,而 Gas 就是计算量的计量单位。例如加法运算较简单,需要消耗 3 个 Gas,除法运算相对复杂,需要 5 个 Gas。

There are random interactions between accounts, transfers between wallets, and calls between contracts. Each chain interaction requires a certain amount of calculation, the size of which is determined by the difficulty of calculating the amount, and Gas is the unit of measure for calculating the amount. For example, a simple addition requires the consumption of three Gas, which is a relatively complex division, and five Gas.

每一单位的 Gas 都有其对应的价格,也就是 Gas 价格 (Gas Price),而 Gas 价格以 Wei 为单位。用户需要购买 ETH 来支付 Gas 费用。1 ETH=1e18 Wei,而我们通常看到的单位 GWei 为 1e9Wei。通常,钱包软件会通过历史 Gas Price 对用户将要发起的这笔交易的费用进行预估。

Each unit's Gas has its corresponding price, that is, Gas Price, which is in the unit of Wei. Users need to purchase ETH to pay for Gas. 1 ETH=1e18 Wei, whereas the unit we usually see is GWeei 1e9Wei. Typically, wallet software estimates the cost of the transaction that the user is about to initiate through history Gas Price.


为了避免全节点趋于集中,追求架构去中心化的区块链会严格限制每单个区块的容量。例如比特币的 Block Size Limit 以及以太坊的 Block Gas Limit。在律动 BlockBeats 撰文时,以太坊每单个区块的 Block Gas Limit 约为 12,000,000 个 Gas,这也就是每一区块总计算量的上限。平均每 15 秒出一区块。当交易需求超过区块容量时,用户为了将自己的交易尽快被上链确认,就需要竞争每一区块内的资源。此时用户会对 Gas 进行竞价,矿工会优先将 Gas Price 高的交易纳入区块。

In order to avoid a concentration of the entire node, a block chain that seeks to centralize the structure would severely limit the capacity of each individual block. For example, Block Size Limited in Bitcoin and Block Gas Limited in Ether. At the time that BlockBeats writes, Block Gas Limited is about 12,000,000 gas per individual block in the ether, which is the upper limit of the total calculation of each block. An average of 15 seconds is available. When a transaction demand exceeds the capacity of a block, users need to compete for resources within each block in order to confirm their transactions as quickly as possible.


通常用户在进行转账时还会看到钱包会提高可以调节 Gas Limit 的选项。与 Block Gas Limit 不同,Gas Limit 是指对于一笔交易,用户所能接受的 Gas 使用量上限。由于有时合约内可能存在漏洞,一笔交易会不停死循环地进行计算。如果没有 Gas Limit,这笔交易会消耗尽用户钱包内所有的 ETH。而矿工通常所收取的费用是按实际执行该交易时消耗的计算量 (Gas Used by Transaction) 进行结算的,而 Gas Limit 内剩余的 ETH 就会回到用户账户中。

Usually, users also see wallets increase the options available to reconcile Gas Limited when making transfers. Unlike Block Gas Limited, Gas Limited refers to the maximum amount of use that the user can accept for a transaction. Because there may be holes in a contract, a transaction is rounded up. In the absence of Gas Limited, the transaction consumes all the ETHs in the user's wallet. Miners usually charge a settlement based on the calculated amount (Gas Used by Trade) that was consumed when the transaction was actually executed, and the remaining ETHs in Gas Limited return to the user's account.

所以我们可以得出,所消耗的 ETH 数量 (Ether Cost)=交易费用 (Gas Fee/Transaction Fee)=每笔交易所消耗的 Gas 数量 (Gas Used By Transaction) * Gas 价格 (Gas Price)。

So we can tell that the quantity of ETH consumed = transaction costs (Gas Fee/Transation Fee) = the number of Gas consumed per exchange (Gas Used By Transport) * Gas Price.

了解了以太坊的手续费机制以及账户类型,我们来看看用户在交易时时常会碰到的问题。

After learning about the Etherm’s fee mechanism and the type of account, we look at the problems that users often encounter when dealing.

待确认交易 (Pending)/加速交易?

pending confirmation of transactions (Pending)/Accelerating transactions?

每当用户发起一笔交易时,交易会被放入一个交易池 (Mempool) 中。如上文提到,矿工会优先打包池子中 Gas Price 最高的交易(矿工的趋利性)。所以用户设定的 Gas Price 决定了交易被打包执行的速度。在网络拥挤的时候,由于 Gas Price 飙升,用户的交易可能长时间处于待确认状态。为了尽快将待定交易发出,用户可以选择支付更多的 Gas Price 来加速交易(律动注:理解为给矿工更多的酬劳以达到一个插队的目的)。

Whenever a user initiates a transaction, the transaction is placed in a trading pool (Mempool). As mentioned above, the mining union gives priority to the highest deal in the pool, Gas Price (the profitability of the miners). So, the user-set Gas Price determines the speed at which the transaction is packaged.

加速交易又是怎么操作的呢?为了更加详细地理解加速交易的逻辑,我们需要明白另一个参数:Nonce。每一个账户发出的交易都会有一个按顺序排列的交易编号--Nonce,从 0 开始,每次发起一笔转账,该账户的 Nonce 值会增加 1。

How does accelerated transactions work? In order to understand the logic of accelerated transactions in more detail, we need to understand another parameter: Nonce. Every transaction from an account has a sequential transaction number -- Nonce, starting with 0, each time a transfer is initiated, the nonce value of the account increases by one.


当用户想要加速交易时,在以太坊钱包中,用户可以选择加速交易选项,这时会被要求支付更高的 Gas 费用,用户同意之后相当于发起了一笔新的交易,而新的交易与待确认交易的 Nonce 值相同。

When users want to speed up transactions, in the Etherno wallet, they can choose the accelerated transaction option, which is required to pay higher Gas fees, and when the user agrees to initiate a new transaction, which is the same as the nence value of the transaction to be confirmed.

由于以太坊网络规定,Nonce 值是连续不可跳跃的,且同一个地址每笔交易的 Nonce 值不可重复,所以矿工会打包新生成的交易,在新交易被打包确认之后,之前较低 Gas Price 的交易会废弃掉。

Since the Nonce value is inconsequential and the Nonce value per transaction at the same address is non-repeal, the mining union packs the newly generated transaction before the lower Gas Price deal is abandoned after the new transaction is confirmed.

若用户不想加速交易,只要此交易还在交易池中未被打包,用户可以随时选择取消交易。取消交易的逻辑与加速交易相同,用户发起一笔 Gas Price 更高,但与待确认交易 Nonce 相同的交易,但交易金额变为 0,所以本质上,取消交易的成本与加速交易的成本一样需要成本。

If the user does not want to accelerate the transaction, the user may choose to cancel the transaction at any time as long as the transaction is not packaged in the pool. The logic of cancellation is the same as accelerated transactions, and the user initiates a higher deal, but the same transaction as the pending transaction Nonce, but the transaction amount is zero, so in essence the cost of cancellation of the transaction is as much as the cost of accelerating the transaction.

需要注意的是,在待定交易确认完成之前,后面的交易都需要排队等候,所以用户不要由于等候时间过长重复发起多笔交易。

It should be noted that until the confirmation of pending transactions is completed, subsequent transactions will need to be queued, so users should not repeat multiple transactions because of long waiting times.

交易失败 (Fail)

transaction failed (Fail)

律动 BlockBeats 发现,目前最常见的交易失败原因是交易 Gas 已用尽 (Out of Gas)。也就是说,这笔交易的计算量超过了用户所设定的 Gas Limit。一般在这种情况下,交易状态将会显示为失败,并提示 Gas 已用尽,并且所支付的 Gas 不会被退还。

BlockBeats finds that the most common reason for the failure of the current transaction is that the transaction Gas has been exhausted (out of Gas). That is to say, the amount of the transaction exceeds the value of Gas Limit set by the user. In this case, the state of the transaction will normally be shown to be a failure and suggest that Gas has been exhausted and that the payments Gas will not be returned.

有些用户可能会认为这并不公平,但本质上矿工已经在做功计算,只是算到一半 Gas 不够了,所以矿工只能放弃继续作业,但之前的工作需要被支付「工资」,因此之前交的 Gas 费不退大概也可以理解了。遇到这种情况,用户只能重新再发起一次交易,并将此交易的 Gas Limit 上调。

Some users may think that this is unfair, but essentially the miners are doing their work, but half of Gas is not enough, so the miners have to give up their work, but the previous work needs to be paid as a “wage”, so it is understandable that the fees previously paid for Gas will not be paid back. In this case, the users can only recommence the transaction and turn it upwards.

另一种交易失败的情况是,当用户向智能合约发起交易转账,但某些错误导致无法执行合约时,交易会返回 Bad Instruction。

In another case where a transaction fails, the transaction returns Bad Instruction when the user initiates a transaction transfer to an intelligent contract, but some errors result in the contract being unenforceable.

比如,当用户参与类似于众筹活动时,可能会发生下面这些情况:

For example, when users are involved in events similar to crowd-movement activities, the following situations may occur:

额度已满;

(a) the amount is full;

或用户未被列入白名单;

or the user is not on the white list;

或用户超额认购代币等情况。

Or over-substantiation by the user.

此时,用户所设置的 Gas Limit 将会被全部用尽,最终导致交易失败。

At this point, the user's set-up of Gas Limited will be exhausted, ultimately leading to a failure of the transaction.

不过以太坊拜占庭硬分叉后,增添了新的操作符 Reverted (EIP-140)。当合约中出现错误导致交易失败时,交易将不会耗尽 Gas Limit 所设定的所有 Gas,合约将停止执行并退回剩余 Gas 费用,同时告知用户错误原因。

However, a new operator, Reverted (EIP-140), has been added after a hard split in the Byzantine court. When an error in the contract results in a failure of the transaction, the transaction will not run out of all Gas that Gas Limited has set, and the contract will be suspended and returned to the remaining Gas costs, while informing the user of the cause of the error.

当然,如果用户钱包中 ETH 的数量不足以支付 Gas 费用时,交易也会被判定为失败。

Of course, if the number of ETHs in the user's wallet is not sufficient to cover Gas costs, the transaction will also be judged to have failed.

在没有热点的时候,以太坊网络一片祥和,所有的转账成本,包括时间和金额都还可控,但当风口到来,大家在网络中就会遇到各种问题,gas 费的逻辑是新人使用钱包时最大障碍。

In the absence of hot spots, the Etherm network is peaceful and all transfer costs, including time and money, can be controlled, but when the wind comes, problems are encountered in the network, and the logic of gas fees is the biggest obstacle to the use of wallets by newcomers.

基本上,在 gas 费会遇到的所有问题,这篇文章都覆盖到了,链上交易并不复杂,说简单点,一切操作有问题,加钱就可以搞定。

Basically, all the problems encountered at Gas Fees are covered in this article, and transactions on the chain are not complicated.

这场运动目前看来,以太坊上流动性挖矿的热潮暂时告一段落,这场运动除了创造出一片泡沫之外,也让更多用户开始习惯钱包的使用,钱包终于成了一个高频使用工具。

The campaign, which now appears to be a temporary end to the tide of mobile mining in the Taiku, has, in addition to creating a bubble, led more users to become accustomed to the use of wallets, which have finally become a high-frequency tool.

而链上交易发生的问题其实也在为钱包的优化提供空间,为新人提供「一键加速」、「一键取消」这样的服务或许将可以在越来越多的钱包中看到。

The problems of chain transactions are also providing space for wallet optimization, and services such as "one key acceleration" and "one key cancellation" for newcomers will probably be seen in a growing number of wallets.

*律动 BlockBeats 提示各位投资者防范追高风险,本文所提观点不构成任何投资建议。

*BlockBeats alerts investors against high risk, and the views presented in this paper do not constitute any investment proposal.

美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

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

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

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

分享:

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

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

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 支付領域投下震撼彈!美國數位銀行Chime疑與GuardPay 神盾支付合作!

    支付領域投下震撼彈!美國數位銀行Chime疑與GuardPay 神盾支付合作!
    2020年,新冠肺炎(COVID-19)疫情加速數位貨幣進展。例如:2019年4月,國際清算銀行(BIS)的調查顯示,在全球66家中央銀行中,沒有一家計畫發行跨境支付的數位貨幣。惟到了2020年10月,BIS支付委員會主席康利夫(Jon Cunliffe)指出,肺炎疫情拉高民眾對無現金支付的需求,迫使各國加快數位貨幣的研發進程日本與韓國於2021年進入數位貨幣試驗階段。直到2019年12月,美國聯邦準備理事會(Fed)都尚無數位貨幣規劃,惟到了2020年2月,Fed已開始研擬...
  • 区块链:交易系统开发指南

    区块链:交易系统开发指南
    播报编辑《区块链:交易系统开发指南》使用通俗易懂的语言,从技术的角度详细介绍了区块链交易系统应有的功能架构及工作原理,让人们能够张开双臂轻松地拥抱区块链技术,享受区块链交易系统带来的惊喜与成就感。《区块链:交易系统开发指南》共分 7 章,第 1~2 章主要介绍区块链及数字货币的基本概念,以及各种公有链的 API 接口;第3~5 章主要介绍区块链交易系统的分类架构及功能; 6 章主要介绍区块链交易系统面临的问题及演进方向;第 7 章对全书做了总结。《区块链:交易系统开发指南》是...
  • 5.14加密货币价格:BTC突破6.2万美元以太坊和山寨币反映市场情绪

    5.14加密货币价格:BTC突破6.2万美元以太坊和山寨币反映市场情绪
    今天,随着比特币(BTC)的价格突破62 000美元的门槛,顶级加密货币的价格反弹了。 此外,以铁大幅上涨,维持在2 900美元的水平。 此外,其他顶尖山硬币,如索拉纳(SOL )、XRP、卡达诺(ADA )也大幅上涨。    今天密钥加密货币价格 1. 比特币价格    在5月14日星期二撰写本文时,比特币价格上升了2.57%,达到62 487.50美元。 另一方面,在过去24小时内,交易量从65.26 % 急剧上升至277亿美元。 与此同时,加密货币的市场价值为...
  • OKEx回应用户质疑:合约交易非期货 平台无机器人

    OKEx回应用户质疑:合约交易非期货 平台无机器人
       热点点 自选股份 数据中心 数据中心 研究和资料中心 资金流动 模拟交易 客户客户 具体来说,OKEx回答用户的问题:合同交易不是期货,平台不是机器人。 金融同步化,3月22日。    昨天下午,OKEx公司就维护先前用户线下的权利问题对同步财务公司作出了回应,指出OKEx公司提供的合同交易不是期货交易,在旗下的业务中没有正式的机器人。 同时,OKEX称,它不会以非法为由对任何投资损失索赔作出答复。 答复全文如下: 同步你的财务! 近日来,...
  • 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)汇率更新时...
标签列表