简体   繁体   English

Truffle 只编译,不部署 - Ganache

[英]Truffle only compiles, does not deploy - Ganache

I have spun up a private blockchain.network using Ganache on port 8545. I have some smart contracts which are being compiled successfully.我在端口 8545 上使用 Ganache 启动了一个私有 blockchain.network。我有一些正在成功编译的智能合约。 However, they aren't being deployed to the connected.network which is localhost:8545但是,它们没有部署到 localhost:8545 的 connected.network

This is my truffle-config.js `这是我的 truffle-config.js `

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*",
    },
  },
  mocha: {},
  compilers: {
    solc: {
      version: "0.8.17"
    }
  }
};

` `

Trying truffle migrate尝试松露迁移

I have tried the following:我尝试了以下方法:

  1. Right-click and deploy - Does not deploy but shows success右键部署-不部署但显示成功
  2. Using migrate --reset which only compiles and then ends使用仅编译然后结束的migrate --reset
  3. Changing the truffle config file multiple times but all in vain多次更改松露配置文件但都是徒劳的
  4. Successfully added my project to Ganache but all the recognised smart contracts are listed as Not Deployed已成功将我的项目添加到 Ganache,但所有已识别的智能合约都列为未部署

Replace the following code in the truffle-config.js :替换truffle-config.js中的以下代码:

 require("babel-register");
 require("babel-polyfill");

// We're settings up our networks to the Ganache Network
module.exports = {
    networks: {
        development: {
            host: "127.0.0.1",
            port: "7545",
            network_id: "*", // Connect to any network
        },
    },

    // The path of contracts folder
    contracts_directory: "./src/contracts",

    // The path of all our JSON Files
    contracts_build_directory: "./src/build/contracts",

    compilers: {
        solc: {
            version: "^0.8.0",
            optimizer: {
                enabled: true,
                runs: 200,
            },
        },
    },
};

It may be helpful and solve the problem!它可能会有所帮助并解决问题!

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

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