Truffle

嘗試在 ganache-cli 中遷移時出現超時錯誤

  • May 31, 2021

我正在嘗試使用 ganache-cli 本地區塊鏈伺服器部署智能合約。我啟動了 ganache-cli 伺服器,這就是我的 truffle-config.js 文件的樣子……

松露-config.js

module.exports = {
 // See <http://truffleframework.com/docs/advanced/configuration>
 // to customize your Truffle configuration!
 networks: {
   development: {
     host: "localhost",
     port: 9545,
     network_id: "*" // Match any network id
   },
   ganache: {
   //  networkCheckTimeout: 1000000,  // gives error: Something went wrong while attempting to connect to the network. Check your network configuration.
     host: "12.0.0.1",
     port: 8545,
     network_id: "*", // Match any network id
   }
 }
};

編譯後-> truffle compile 然後遷移-> truffle migrate –reset –network ganache,我收到此錯誤…

錯誤資訊

Error: There was a timeout while attempting to connect to the network.
      Check to see that your provider is valid.
      If you have a slow internet connection, try configuring a longer timeout in your Truffle config. Use the networks[networkName].networkCheckTimeout property to do this.

我已經在這篇文章中清除了我的 DNS 記憶體。我重新啟動了系統。解除安裝 ganache-cli 然後安裝它。沒有鍛煉,仍然得到同樣的錯誤。順便說一句,我的網際網路並不慢。

任何人,請幫助。卡在這個問題上好幾天了。我在網際網路上找不到解決方案。所以我把它貼在這裡。

版本

Ganache CLI v6.12.2 (ganache-core: 2.13.2) Truffle v5.3.7 (core: 5.3.7) Solidity v0.5.16 (solc-js) Node v12.21.0 Web3.js v1.3.6

嘗試將開發埠號更改為 8545。

development: {
     host: "localhost",
     port: 9545,
     network_id: "*" // Match any network id
   },

並把這段程式碼評論再試一次。它非常適合我。

//ganache: {
   //  networkCheckTimeout: 1000000,  // gives error: Something went wrong while attempting to connect to the network. Check your network configuration.
    // host: "12.0.0.1",
   //  port: 8545,
  //   network_id: "*", // Match any network id
 //  }

引用自:https://ethereum.stackexchange.com/questions/100011