Truffle

使用 Infura 部署時出現 Truffle 部署錯誤(錯誤:已呼叫回調)

  • July 29, 2020

我正在嘗試使用 Infura 將令牌智能合約部署到 Ropsten 測試網路,但我在使用時總是遇到錯誤

松露遷移 –reset –network ropsten_infura

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



/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:358
               callback(err);
^
Error: Callback was already called.
   at /usr/local/lib/node_modules/truffle/build/webpack:/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:43:1
   at WriteStream.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:358:1)
   at WriteStream.emit (events.js:315:20)
   at WriteStream.destroy (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/level-ws/level-ws.js:140:1)
   at finish (_stream_writable.js:681:14)
   at processTicksAndRejections (internal/process/task_queues.js:84:21)

這是我的 truffle-config.js配置文件:

const path = require("path");
require("dotenv").config({path: "./.env"});
const HDWalletProvider = require("@truffle/hdwallet-provider");
const AccountIndex = 0;

module.exports = {
 // See <http://truffleframework.com/docs/advanced/configuration>
 // to customize your Truffle configuration!
 contracts_build_directory: path.join(__dirname, "client/src/contracts"),
 networks: {
   development: {
     port: 7545,
     host: "127.0.0.1",
     network_id: 5777
   },
   ganache_local: {
     provider: function() {
       return new HDWalletProvider(process.env.MNEMONIC , "http://127.0.0.1:7545", AccountIndex)
     },
     network_id: 5777
   },
   goerli_infura: {
     provider: function() {
       return new HDWalletProvider(process.env.MNEMONIC, "https://goerli.infura.io/v3/INFURAKEY", AccountIndex);
     },
     network_id: 5
   },
   ropsten_infura: {
     provider: function() {
       return new HDWalletProvider(process.env.MNEMONIC, "https://ropsten.infura.io/v3/INFURAKEY", AccountIndex);
     },
     network_id: 3
   } 
 },
 compilers: {
   solc: {
     version: "0.6.1"
   }
 }
};

我在用:

  • 松露5.1.23
  • npm 6.14.4
  • 節點14.0.0
  • 松露-hdwallet-provider 1.0.34

預先感謝您的幫助 !

我有同樣的問題,在四處詢問並蒐索了一下之後,這是快速解決方案和原因。

我的設置是:Truffle v5.1.31 node v14.4.0 Solidity v0.5.0

  1. 將 ndoe 降級到 12,這不是我想要的,所以我找到了方法 2
  2. 執行“truffle migrate –network ropsten –skipDryRun”

https://github.com/trufflesuite/truffle/issues/3008

因為 ganache-cli 的內部核心還不兼容 node 14,所以正如 Cruz Molina 在上一期中所解釋的那樣,空執行。

遇到了同樣的問題,它似乎出現在 Node 14 上。我沒有收到 Node v13 的錯誤

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