Truffle

從松露遷移部署到 Rinkeby 時出現超時錯誤

  • February 4, 2022

我剛剛完成了 CryptoZombies 教程,並試圖按照他們的指示將文件部署到 Rinkeby 網路。但是我不斷收到此超時錯誤,並且不知道如何繼續。

$truffle migrate --network rinkeby

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.


/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56
       throw new Error(errorMessage);
^
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.
   at Timeout._onTimeout (/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56:1)
   at listOnTimeout (internal/timers.js:531:17)
   at processTimers (internal/timers.js:475:7)

我的 truffle-config.js 如下:

const HDWalletProvider = require("truffle-hdwallet-provider");

const mnemonic = "depth invite butter ...";

module.exports = {

 networks: {

   mainnet: {
     provider: function () {

       return new HDWalletProvider(mnemonic, "https://mainnet.infura.io/v3/YOUR_TOKEN")
     },
     network_id: "1"
   },

   rinkeby: {

     provider: function () {

       return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/YOUR_TOKEN")
     },

     network_id: 4
   }
 }
}; 

在學習區塊鏈開發的複雜性和聯繫時,保持冷靜是很重要的。

在這種情況下,我所遵循的教程並不清楚,但要實際部署到任何網路,您需要創建一個項目 id/token。

在這種情況下,當我試圖通過 Infura.io 部署到 Rinkeby 測試網路時 –> 我必須訪問網站並創建賬戶,然後創建一個項目,以及我在松露中替換的項目密鑰/ID配置和你瞧!現在可以了。

我通過在 truffle-config.js 中設置提供程序之前將networkCheckTimeout設置為10000解決了這個問題。

networks: {
 bsctest: {
     networkCheckTimeout: 10000, 
     provider: () => new HDWalletProvider(mnemonic, `https://data-seed-prebsc-1-s1.binance.org:8545/`),
     network_id: 97,
     confirmations: 10,
     timeoutBlocks: 2000,
     skipDryRun: true
   }
}

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