“ Web3ProviderEngine不支持同步请求”

时间:2019-09-22 09:24:29

标签: ethereum solidity web3 truffle

我想用提供程序配置truffle-config.js。当我运行命令“ truffle migration --network ropsten”时,出现标题显示错误

Error: Web3ProviderEngine does not support synchronous requests.

错误详细信息告知

at Object.run (C:\Users\Bruce\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:92:1)

我对此一无所知。我寻找档案 “ C:\ Users \ Bruce \ AppData \ Roaming \ npm \ node_modules \ truffle \ build \ webpack:\ packages \ truffle-migrate \ index.js:92:1” ,但我找不到webpack下的路径"build/"。有什么不对吗?我使用global安装松露,并且在默认网络ganache下可以很好地运行。

ropsten: {
      provider: () => new HDWalletProvider(
        privateKeys.split(','),
        `https://ropsten.infura.io/v3/${process.env.INFURA_API_KEY}`
      ),
      network_id: 3,       // Ropsten's id, mainnet is 1
      gas: 5500000,        // Ropsten has a lower block limit than mainnet
      gasPrice: 2500000000, //2.5 gwei
      confirmations: 2,    // # of confs to wait between deployments. (default: 0)
      timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
      skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
    },

我的HDWalletProvider依赖版本:

 "dependencies": {
    "chai": "^4.2.0",
    "chai-as-promised": "^7.1.1",
    "dotenv": "^8.1.0",
    "eslint": "^6.4.0",
    "openzeppelin-solidity": "^2.3.0",
    "truffle-hdwallet-provider": "^1.0.17",
    "truffle-hdwallet-provider-privkey": "^0.3.0",
    "web3": "^1.2.1"
  },

迁移:

1_initial_migration.js

const Migrations = artifacts.require("Migrations");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

2_deploy_contract.js

const Token = artifacts.require("TokenInstance");
const DeleToken = artifacts.require("DelegateToken")
module.exports = async function(deployer) {

  deployer.deploy(Token);
  deployer.deploy(DeleToken);

};

它只是无法成功编译。但是我用ganache使用默认网络就可以了!

1 个答案:

答案 0 :(得分:1)

您仍在使用已过时的旧存储库。

您应该改用松露monorepo

npm install @truffle/hdwallet-provider

并替换

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

您也不需要使用truffle-hdwallet-provider-privkey