0

我无法迁移 truffle init 附带的标准合同。这是我的工作:

truffle init
truffle compile
truffle migrate

这就是我初始化时生成的内容:

在此处输入图像描述

但是当我迁移时,会显示以下错误列表:

Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/errors.js:35:16)
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:115:32)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:64:18)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:354:12)
at XMLHttpRequest._onHttpRequestError (/usr/local/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:544:12)
at ClientRequest.<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:414:24)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:309:9)
at emitOne (events.js:96:13)
4

3 回答 3

2

正如网络迷评论:

  1. testrpc
  2. 检查您的 truffle.js 配置端口,并将 ip 设置为默认 'localhost:8545'
  3. truffle migrate
于 2017-05-24T09:33:20.483 回答
1

对于 Solidty 要迁移,本地以太坊区块链应该已经运行,并且您要迁移的智能合约应该转到正确的本地以太坊区块链,因此您需要检查本地以太坊区块链的端口号。

  1. ganache-clitestrpc(用于制作本地区块链)。它的下面写着它正在运行的端口号。比如http://localhost:8545
  2. 转到truffle.js文件并检查端口应该是8545.
  3. 现在使用 迁移智能合约truffle migrate
于 2018-03-13T08:06:04.377 回答
0

合约名称不应与函数名称相同。

于 2019-02-27T13:01:41.857 回答