我如何在区块链网络上部署我的合同?

时间:2020-06-20 12:45:55

标签: blockchain ethereum truffle ganache

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)

1 个答案:

答案 0 :(得分:0)

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

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

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