简体   繁体   English

松露迁移错误

[英]truffle migrate Error

I can´t migrate the standart contracts that come with truffle init. 我无法迁移松露init随附的标准合约。 Here´s what i do: 这是我的工作:

truffle init
truffle compile
truffle migrate

and this is what it generates when i init: 这就是我初始化时生成的内容:

在此处输入图片说明

But when i migrate , the following list of errors shows up: 但是当我迁移时,出现以下错误列表:

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)

As webjunkie comments: 正如webjunkie所说:

  1. testrpc
  2. Check your truffle.js config port and ip is set to default 'localhost:8545' 检查您的truffle.js配置端口并将ip设置为默认的'localhost:8545'
  3. truffle migrate

For Solidty To Migrate, The Local Ethereum Blockchain should be running already and the Smart Contract you want to migrate should go to the correct Local Ethereum Blockchain so you need to check the Port Number of the Local Ethereum Blockchain. 对于要迁移的Solidity,本地以太坊区块链应该已经在运行,并且要迁移的智能合约应该转到正确的本地以太坊区块链,因此您需要检查本地以太坊区块链的端口号。

  1. ganache-cli or testrpc (For Making a local Blockchain). ganache-clitestrpc (用于制作本地区块链)。 It has the port number on which it is running written beneath. 它的下面写有正在运行的端口号。 Such as http://localhost:8545 . http://localhost:8545
  2. Go to truffle.js file and check that port should be 8545 . 转到truffle.js文件,并检查端口应为8545
  3. Now Migrate the Smart Contract using truffle migrate . 现在,使用truffle migratetruffle migrate智能合约。

合同名称不应与功能名称相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM