"Web3ProviderEngine does not support synchronous requests" when running truffle migrate
Asked Answered
S

1

5

I wanted to config my truffle-config.js with provider. When I run command "truffle migrate --network ropsten", it throws this error:

Error: Web3ProviderEngine does not support synchronous requests.

And the error details told

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

I have no idea about this. I look for the file "C:\Users\Bruce\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:92:1", but I cannot find the path webpack under the "build/". Is it somethind wrong? I install truffle with global and it runs well with default network 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 )
    },

My HDWalletProvider dependency version:

 "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"
  },

And the migrations:

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);

};

It just cannot compile successfully. But I use the default network with ganache is OK!

Surber answered 22/9, 2019 at 9:24 Comment(2)
What version of HDWalletProvider fo you use? And can you show your migration files?Cholula
I have added some details for the problem. Thank you!Surber
C
7

You are still using the old repository that has been deprecated.

You should use truffle monorepo instead

npm install @truffle/hdwallet-provider

and replace

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

also you don't need to use truffle-hdwallet-provider-privkey

Cholula answered 23/9, 2019 at 3:18 Comment(2)
Great! And must the Migrations.sol contract be deployed everytime I deploy a contract?Surber
You can read more about how the migration works there medium.com/@blockchain101/…Cholula

© 2022 - 2024 — McMap. All rights reserved.