Out of gas的解决方案 Although one or more Error Occurred [out of gas] Contract Execution Completed

简介: 该文章分析了以太坊交易中出现"Out of Gas"错误的原因,并提供了通过MetaMask客户端设置更高的Gas Limit来解决这一问题的详细步骤和建议。

问题表现和分析

https://goerli.etherscan.io/tx/0x108fc2846950d188829c25bccbbdca5e844b42f5426d9b9bbc8ca77ab13f9d98

上图的绿框提示了out of gas错误,并且Gas Limit & Usage by Txn已经达到了设置100%,说明小狐狸设置的Gas Limit不够了。

解决方案

客户端对小狐狸进行设置,具体步骤如下:

  1. 在发送交易时弹出上点击【建议的网站】

  1. 在建议的网站页面,点击【高级】

  1. 在高级的弹出窗中,点击【燃料限制】进行编辑

  1. 编辑【燃料限制】后进行保存即可

注意⚠️:这样的修改仅仅适用于本次的交易提交,要修改为默认需从 高级 进行设置。

此时,再进行提交发现成功了,scan页面如下:

可以看到提交之后Gas Limit & Usage by Txn实际需要 67,827 (18.18%),此时仅仅使用了Gas Limit的18.18%

问题和解决方案分析

先理解Gas Price和Gas limit。

  1. Gas Price是指,Gas的单价,即每个Gas值多少Ether。单价越高,矿工们就会越优先打包你的交易,你的交易完成的速度就会越快。但是调高Gas price并不能解决OOG(Out of Gas 下同)的问题。
  1. Gas limit是指,本次交易最多可花费多少Gas的上限。调高它就可以解决大部分的OOG问题,并且,调高它并不会提高你的Gas花费,剩余的Gas会重新返还到你的账户当中的。

但是也不能太高,高过创世节点配置的最大值,否则就会出现这样的错误:

{"code":-32000,"message":"exceeds block gas limit"}

Out of gas同类错误提示

Warning! Error encountered during contract execution [**Out of gas**]
或者是
Although one or More Error Occured [**Out of gas**] Contract Execution Completed

相关文章
|
11月前
|
Web App开发 前端开发
【前端异常】Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
【前端异常】Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
639 0
|
数据库
面向失败的设计-Planning for failure
这篇文章,将会介绍如何把结构化状况以及应对方式,从而得以以系统地方式沉淀积累,成为可复用的预案;最后,文章会结合阿里巴巴10年大促的实践,给出实践预案的原则性建议。
1639 0
|
1月前
|
JavaScript 前端开发
NodeJs——error:03000086:digital envelope routines::initialization error
NodeJs——error:03000086:digital envelope routines::initialization error
43 0
|
4月前
|
JavaScript 安全 网络安全
Node: opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error‘ ]异常处理
Node: opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error‘ ]异常处理
1841 0
|
4月前
|
JavaScript 程序员 Swift
The compiler is unable to type-check this expression in reasonable time; try breaking up the express
The compiler is unable to type-check this expression in reasonable time; try breaking up the express
57 0
|
4月前
|
算法 JavaScript
解决Error: error:0308010C:digital envelope routines::unsupported最快速方案
解决Error: error:0308010C:digital envelope routines::unsupported最快速方案
225 0
|
4月前
|
安全
Error:Execution failed for task ':transformClassesAndResourcesWithProguardForRelease'
Error:Execution failed for task ':transformClassesAndResourcesWithProguardForRelease'
40 0
|
4月前
|
机器学习/深度学习 Java Android开发
记录一个Flutter运行的异常FAILURE: Build failed with an exception. What went wrong: A problem occurred config
记录一个Flutter运行的异常FAILURE: Build failed with an exception. What went wrong: A problem occurred config
155 0
Optimization loop failed: Cancelled: Operation was cancelled解决方案
Optimization loop failed: Cancelled: Operation was cancelled解决方案
307 0
Optimization loop failed: Cancelled: Operation was cancelled解决方案
PowerDesigner在生成SQL时报错Generation aborted due to errors detected during the verification of the mod
PowerDesigner在生成SQL时报错Generation aborted due to errors detected during the verification of the mod
533 0
PowerDesigner在生成SQL时报错Generation aborted due to errors detected during the verification of the mod