【问题标题】:Solidity | Truffle | Web3 | Gas Limit坚固性 |松露 |网络3 |气体限制
【发布时间】:2018-11-06 00:23:54
【问题描述】:

我正在尝试在 rinkeby 测试网上使用以下代码部署联系人:

    const result = await new web3.eth.Contract(JSON.parse(interface))
        .deploy({data: bytecode, arguments: [100, accounts[0]]})
        .send({gas: 1000000, from: accounts[0]});

Attempting to deploy from acount  0xBE80D3f83530f2Ed1214BE5a7434E0cd32177047
(node:3862) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: The contract code couldn't be stored, please check your gas limit.

When I increase the gas limit to 10000000
I get below error. Not able to understand what is wrong with the deployment

Attempting to deploy from acount  0xBE80D3f83530f2Ed1214BE5a7434E0cd32177047
(node:3870) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: exceeds block gas limit

【问题讨论】:

  • 你能出示你的合同吗?这个gas限制似乎太低了。

标签: mocha.js solidity web3 truffle


【解决方案1】:

您超出了 gas 限制。您可能在构造函数上做了太多工作,或者您只是发送了太低的 gas 限制。

Rinkeby gas 限制在7.4M 左右,因此您可以尝试将 gas 从:1M 增加到 ~7.4M。

如果你的合约很大,你可以把它分成多个合约,或者像我之前说的那样减少构造函数上的工作。

【讨论】:

    猜你喜欢
    • 2018-01-18
    • 1970-01-01
    • 2018-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多