【发布时间】:2018-03-20 09:09:47
【问题描述】:
我可以使用 Truffle 和 Ganache-cli。已经部署了合约并且可以使用 truffle 控制台玩它
truffle(development)>
Voting.deployed().then(function(contractInstance)
{contractInstance.voteForCandidate('Rama').then(function(v)
{console.log(v)})})
undefined
truffle(development)> { tx:
'0xe4f8d00f7732c09df9e832bba0be9f37c3e2f594d3fbb8aba93fcb7faa0f441d',
receipt:
{ transactionHash:
'0xe4f8d00f7732c09df9e832bba0be9f37c3e2f594d3fbb8aba93fcb7faa0f441d',
transactionIndex: 0,
blockHash:
'0x639482c03dba071973c162668903ab98fb6ba4dbd8878e15ec7539b83f0e888f',
blockNumber: 10,
gasUsed: 28387,
cumulativeGasUsed: 28387,
contractAddress: null,
logs: [],
status: '0x01',
logsBloom: ... }
现在,当我使用“npm run dev”启动服务器时。服务器启动正常,但没有连接到区块链
我收到了错误
Uncaught (in promise) Error: Contract has not been deployed to detected network (network/artifact mismatch)
这是我的 truffle.js
// Allows us to use ES6 in our migrations and tests.
require('babel-register')
module.exports = {
networks: {
development: {
host: '127.0.0.1',
port: 8545,
network_id: '*', // Match any network id
gas: 1470000
}
}
}
你能指导我如何连接吗?
【问题讨论】:
-
你应该尝试在以太坊 stackexchange 网站上询问这个问题。
-
我也在 gitter 上问过。到目前为止没有运气。感谢您的评论。
-
如果您正在获取 truffle 开发控制台(因为我看到了
truffle(development)>)...这是否意味着您正在使用 truffle 开发 rpc(通过使用truffle develop)?那是端口 9545。
标签: npm blockchain ethereum truffle consensys-truffle