为松露设置气体

Mat*_*lly 5 ethereum truffle consensys-truffle go-ethereum cryptocurrency

truffle migrate在 main 上运行。也使用geth。我最初在 truffle.js 中将 Gas Price 和 Gas 留空,但现在看起来像这样:

live: {
  network_id: 1,
  host: "127.0.0.1",
  port: 8545,
  from: "3984bc76cb775d7866d1cd55c4f49e3d13d411d4",
  gas: 40000,
  gasPrice: 22000000000 // Specified in Wei
}
Run Code Online (Sandbox Code Playgroud)

我似乎遇到了一种情况,要么汽油太多,要么汽油不足,不可能获得适量的汽油。

 <   {
 <     "jsonrpc": "2.0",
 <     "id": 2,
 <     "error": {
 <       "code": -32000,
 <       "message": "insufficient funds for gas * price + value"
 <     }
 <   }
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: insufficient funds for gas * price + value
Run Code Online (Sandbox Code Playgroud)

...或者...

 <   {
 <     "jsonrpc": "2.0",
 <     "id": 2,
 <     "error": {
 <       "code": -32000,
 <       "message": "exceeds block gas limit"
 <     }
 <   }
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: exceeds block gas limit
Run Code Online (Sandbox Code Playgroud)

当我web3.eth.getBlock("latest")在控制台中运行时,我得到gasLimit: 5000. 当我将 Gas 设置为 5000 时,我收到资金不足的消息。当我将其设置为 5001 时,我得到“超出块气体限制”。

所以,这一切似乎都在告诉我,gasLimit 应该设置为 5000 或低于 5000,但在这种情况下,我没有足够的资金来运行交易。让我们来看看...

我有:

Gas: 5000, GasPrice: 22000000000 // 以 Wei 为单位

5000 * 22000000000 = 1.1 * 10^14 = 110,000,000,000,000 Wei 1.1 * 10^14 / 10 ^ 18 (1 以太币中的 Wei 数量) = 1.1*10^-4 ETH

这是我正在使用的帐户:https://etherscan.io/address/0x3984bc76cb775d7866d1cd55c4f49e3d13d411d4。正如你所看到的,它有资金。准确地说,在撰写本文时为 0.01738465 以太币。

Mat*_*lly 1

这随机地在第二天开始工作。我注意到的一件事是,当我web3.eth.getBlock("latest")昨天在 truffle 控制台中运行时,我得到了gasLimit: 5000,这个数字比网络在其他地方报告的要低得多。今天我得到了gasLimit: 6706583。我真的不确定是什么导致本地燃气限制增加,但无论如何似乎已经解决了问题。