以太坊松露MetaCoin失败,“内在气体太低”

时间:2017-03-03 21:54:14

标签: ethereum truffle

与标题中所述相似,在进行松露测试后,我得到了这个:

 TestMetacoin
    1) "before all" hook: prepare suite

  Contract: MetaCoin
    ✓ should put 10000 MetaCoin in the first account
    2) should call a function that depends on a linked library
    > No events were emitted
    ✓ should send coin correctly (6078ms)


  2 passing (6s)
  2 failing

  1) TestMetacoin "before all" hook: prepare suite:
     Error: Intrinsic gas too low
      at Object.InvalidResponse (/usr/lib/node_modules/truffle/node_modules/truffle-contract/node_modules/web3/lib/web3/errors.js:35:16)
      at /usr/lib/node_modules/truffle/node_modules/truffle-contract/node_modules/web3/lib/web3/requestmanager.js:86:36
      at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:119:13)
      at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:64:18)
      at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:354:12)
      at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:509:12)
      at IncomingMessage.<anonymous> (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:469:24)
      at endReadableNT (_stream_readable.js:974:12)
      at _combinedTickCallback (internal/process/next_tick.js:74:11)
      at process._tickDomainCallback (internal/process/next_tick.js:122:9)

  2) Contract: MetaCoin should call a function that depends on a linked library:
     AssertionError: Library function returned unexpected function, linkage may be broken: expected 0 to equal 20000
      at test/metacoin.js:25:14
      at process._tickDomainCallback (internal/process/next_tick.js:129:7)

我的创世块如下:

{
    "nonce": "0x0000000000000042",
    "difficulty": "0x4000",
    "alloc": {
            "0xfd0ceb7965a0e4c3146c1f901fbab9668653af6b": {
            "balance": "325406000000000"
        }
    },
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0xfd0ceb7965a0e4c3146c1f901fbab9668653af6b",
    "etherbase" : "0xfd0ceb7965a0e4c3146c1f901fbab9668653af6b",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x",
    "gasLimit": "0x3d0900"
}

我的truffle.js是这样的:

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*", // Match any network id
      gas: 1000000
    }
  }
};

我无法理解这些设置的气体有什么问题。即使没有人有确切的答案,对气体限制的一些额外解释(不是气体本身)也会有所帮助。

1 个答案:

答案 0 :(得分:0)

我最终将genesis block gasLimit更改为

"gasLimit": "0x2FEFD800", 

将宅基地块配置为10(显然在使用geth时存在问题):

"config": {
            "homesteadBlock": 10
    },

和truffle.js将气体设置为5000000.

测试通过。

相关问题