Solidity

使用 truffle 和 metamask 在 rinkeby 上部署合約失敗

  • April 4, 2021

以下是我的 truffle-config.js 文件中的一個片段

 networks: {
   // Useful for testing. The `development` name is special - truffle uses it by default
   // if it's defined here and no other network is specified at the command line.
   // You should run a client (like ganache-cli, geth or parity) in a separate terminal
   // tab if you use this network and you must also set the `host`, `port` and `network_id`
   // options below to some value.
   //
   development: {
     host: "127.0.0.1",     // Localhost (default: none)
     port: 8545,            // Standard Ethereum port (default: none)
     network_id: "*",       // Any network (default: none)
   },

   rinkeby: {
     provider: function () {
       return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3*************************************");
     },
     from: "0xe95745a8F4E3cDb1cF5bfFD4A94F0B249e99f489",
     network_id: 4,
     gas: 4500000,
     gasPrice: 10000000000,
   }

我正在嘗試使用 metamask 生成的地址在 rinkeby 上部署我的合約。但是,當我執行truffle migrate --network rinkeby它時,它給了我以下錯誤:

C:\Users\DELL\AppData\Roaming\npm\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 (C:\Users\DELL\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\provider\index.js:56:1)
   at listOnTimeout (internal/timers.js:549:17)
   at processTimers (internal/timers.js:492:7)

為什麼會發生這種情況的任何建議。

發現錯誤。這是一個錯字。提供商連結https://rinkeby.infura.io/v36c中的 v3 後缺少一個括號 。已更改為https://rinkeby.infura.io/v3/6c …。

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