繁体   English   中英

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

[英]How can i deploy my contract on blockchain network?

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

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

暂无
暂无

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

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