【问题标题】:migration run out of gas迁移气体耗尽
【发布时间】:2019-08-17 06:56:53
【问题描述】:

您好,我正在使用 Geth,我尝试 truffle 迁移,但它给出了错误。 truffle-config.js 如下:

development: {
  host: "127.0.0.1",     // Localhost (default: none)
  port: 8545,            // Standard Ethereum port (default: none)
  network_id: "4",       //rinkeby id
  from:"my address",
  gas: 1000   
 }

当我使用命令 -truffle migrate 进行 truffle 迁移时,我收到此错误。

 Error: Error: Error:  *** Deployment Failed ***
 "Migrations" ran out of gas (using a value you set in your network 
  config or deployment parameters.)
  * Block limit:  0x50e7c
  * Gas sent:     1000

at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-migrate/index.js:92:1)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

你能帮帮我吗?

【问题讨论】:

    标签: blockchain truffle geth


    【解决方案1】:

    这正是错误所说的。 gas 用完了(使用您在网络中设置的值 配置或部署参数。)

    gas: 1000 不足以部署你的合约

    【讨论】:

    • 我应该写什么,因为当我写 gas:4700000it 时也会出现同样的错误。我尝试了很多数字
    • 您可以尝试6800000,因为您部署到rinkeby。您还可以通过 solc --gas yourContract.sol 估算您的合约需要多少 gas
    【解决方案2】:

    我通过将此代码添加到 truffle 配置文件中解决了该错误。

       compilers: {
        solc: {
          version: "0.5.16",
          settings: {
            optimizer: {
              enabled: true, // Default: false
              runs: 1000, // Default: 200
            },
          },
        },
      },
    

    【讨论】:

    • 请在您的回答中提供更多详细信息。正如目前所写的那样,很难理解您的解决方案。
    猜你喜欢
    • 2022-10-23
    • 2020-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-18
    • 2020-02-10
    • 2021-08-13
    • 1970-01-01
    相关资源
    最近更新 更多