0
I've being trying to create a basic smart contract and deploy it on blockchain using truffle,ganache.When i put this command on my truffle console it throws an error.I've looked for the solution but can't seem to understand where i am going wrong!Can anyone help me out?

这是我的迁移第二个文件,即 2_deploy_contracts.sol

var Election = artifacts.require("./Election.sol");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

这是我的 truffle-config.js

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // for more about customizing your Truffle configuration!
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*" // Match any network id
    },
    develop: {
      port: 8545
    }
  }
};

这是错误:

Uncaught:
Error: Election has not been deployed to detected network (network/artifact mismatch)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Function.deployed (C:\Users\harshad\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\contract\constructorMethods.js:84:1)
    at Object.checkNetworkArtifactMatch (C:\Users\harshad\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\utils\index.js:249:1)
4

1 回答 1

0

我认为专用网络未连接到您的松露。请检查以下内容:

  1. 私有链开发工具(ex.Ganache)正在运行。
  2. 检查私有链(Ganache)IP 和 RPC 端口号是否与 truffle-config.js 文件中的相同。

这将是这个问题的解决方案。

于 2020-06-26T01:30:36.730 回答