Open bjornharvold opened 6 years ago
I am having the same error as well on ropsten
. Here's my truffle.js
:
// See <http://truffleframework.com/docs/advanced/configuration>
// for more about customizing your Truffle configuration!
var HDWalletProvider = require("truffle-hdwallet-provider");
var infura_apikey = "XXXXXXXXXXXXXXX";
var mnemonic = "<REPLACE THIS WITH YOUR METAMASK SEED PHRASES>";
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
gas: 6500000,
network_id: "5777" // "*" Matches ANY network id
},
ropsten: {
provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/" + infura_apikey),
network_id: 3,
gas: 4500000
}
},
solc: {
optimizer: {
enabled: true,
runs: 200
}
}
};
Here's the error:
ray@ray-laptop ~/s/test-token> truffle migrate --network ropsten
Using network 'ropsten'.
Running migration: 2_XaiCrowdsale.js
/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-error/index.js:10
this.stack = (new Error(message)).stack;
^
Error: Web3ProviderEngine does not support synchronous requests.
at ProviderError.ExtendableError (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-error/index.js:10:1)
at new ProviderError (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/error.js:17:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:71:1
at HDWalletProvider.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:109:1)
at Object.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:209:1)
at RequestManager.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:58:1)
at Eth.get [as blockNumber] (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/property.js:107:1)
at module.exports (/home/ray/src/test-token/migrations/2_TestCrowdsale.js:4:48)
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:82:1
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-require/require.js:101:1
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:532:3)
Any help much appreciated!!
The same for me on Ropsten, same configuration of @iamraybao :
$ truffle migrate --network ropsten --reset Using network 'ropsten'. Running migration: 1_initial_migration.js Replacing Migrations... ... 0x2b17ae780b9aff83c0396a29d37034f9e544a48f64eb4f4a6c3cefdfa32bffdf Migrations: 0x6ddf885839a7572773ae97140d9a536e71ae4c77 Saving successful migration to network... ... 0x44ba53718fadb3f46b16a8c216e9fd6d3ea210bff0136f503226de99206ad921 Saving artifacts... Running migration: 2_deploy_token.js Replacing HVT... ... 0xfc554a54518bc2adf5090a34011d1b57e5afdb8ed3e814a132f9d0719db98081 HVT: 0xf147fde4dd0086cb5907400596c6451959db35a4 Saving successful migration to network... ... 0x53320f16702de4693f7a605413b45edb2083b11d5e3fa9a72d490ae3287244cf Saving artifacts... Running migration: 3_deploy_tokenSale.js /usr/lib/node_modules/truffle/build/cli.bundled.js:128857 var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&"function"==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRO Error: Web3ProviderEngine does not support synchronous requests. at ProviderError.ExtendableError (/usr/lib/node_modules/truffle/build/webpack:/~/truffle-error/index.js:10:1) at new ProviderError (/usr/lib/node_modules/truffle/build/webpack:/~/truffle-provider/error.js:17:1) at /usr/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:71:1 at HDWalletProvider.send (/usr/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:109:1) at Object.send (/usr/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:209:1) at RequestManager.send (/usr/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:58:1) at Eth.get [as blockNumber] (/usr/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/property.js:107:1) at module.exports (/home/dstreppa/development/hive/truffle/HivePowerCrowdsale/migrations/3_deploy_tokenSale.js:38:51) at /usr/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:82:1 at /usr/lib/node_modules/truffle/build/webpack:/~/truffle-require/require.js:101:1
Anybody know a workaround?
I got the same error. I was successful with the same deployment script few weeks ago.
PS C:\devel\DHCoin> truffle migrate --network ropsten
Using network 'ropsten'.
Running migration: 2_deploy_contracts.js
C:\Users\grand\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-error\index.js:10
this.stack = (new Error(message)).stack;
^
Error: Web3ProviderEngine does not support synchronous requests.
at ProviderError.ExtendableError (C:\Users\grand\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-error\index.js:10:1)
at new ProviderError (C:\Users\grand\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-provider\error.js:17:1)
at C:\Users\grand\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-provider\wrapper.js:71:1
at HDWalletProvider.send (C:\Users\grand\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-provider\wrapper.js:109:1)
at Object.send (C:\Users\grand\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-migrate\index.js:209:1)
at RequestManager.send (C:\Users\grand\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\requestmanager.js:58:1)
at Eth.send [as getBlock] (C:\Users\grand\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\method.js:145:1)
at module.exports (C:\devel\DHCoin\migrations\2_deploy_contracts.js:5:34)
at C:\Users\grand\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-migrate\index.js:82:1
at C:\Users\grand\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-require\require.js:101:1
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
with the configuration
var HDWalletProvider = require("truffle-hdwallet-provider");
var infura_apikey = "DELETED";
var mnemonic = "DELETED";
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*" // Match any network id
},
ropsten: {
provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"+infura_apikey),
network_id: 3
, gas: 3000000
}
}
};
I am having the same error as well on ropsten.
Facing same problem
has anyone find any solutions.?
Same trouble:
$ npx truffle migrate --network infura_rinkeby
Using network 'infura_rinkeby'.
Running migration: 1_initial_migration.js
/home/kostysh/example/node_modules/truffle/build/webpack:/~/truffle-error/index.js:10
this.stack = (new Error(message)).stack;
^
Error: Web3ProviderEngine does not support synchronous requests.
at ProviderError.ExtendableError (/home/kostysh/example/node_modules/truffle/build/webpack:/~/truffle-error/index.js:10:1)
at new ProviderError (/home/kostysh/example/node_modules/truffle/build/webpack:/~/truffle-provider/error.js:17:1)
at /home/kostysh/example/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:71:1
at HDWalletProvider.send (/home/kostysh/example/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:109:1)
at Object.send (/home/kostysh/example/node_modules/truffle/build/webpack:/~/truffle-core/~/truffle-migrate/index.js:209:1)
at RequestManager.send (/home/kostysh/example/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:58:1)
at Eth.send [as getBalance] (/home/kostysh/example/node_modules/truffle/build/webpack:/~/web3/lib/web3/method.js:145:1)
at module.exports (/home/kostysh/example/migrations/1_initial_migration.js:10:29)
at /home/kostysh/example/node_modules/truffle/build/webpack:/~/truffle-core/~/truffle-migrate/index.js:82:1
at /home/kostysh/example/node_modules/truffle/build/webpack:/~/truffle-require/require.js:101:1
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:528:3)
currently used versions: "truffle": "4.1.7", "truffle-hdwallet-provider": "0.0.5"
Just found a solution. I have reached out that the source of the trouble is in the synchronous manner of calling web3.eth.getBalance method (I am checking the account balance at the beginning of migrations script). Only Http Provider can support calling of this method synchronously. This works if you test your migrations locally (with ganache, for example), but this will not work with assync providers like hdwallet-provider or privatekey-provider. So if you want to call any web3 methods during migrations (with truffle) you need to use methods callbacks or just use the promises. Here the simple example of how you can cover web3.eth.getBalance with Promise and then use it in migrations sctipt (file: 1_initial_migration.js):
const Migrations = artifacts.require('Migrations');
const checkBalance = account => new Promise((resolve, reject) => {
web3.eth.getBalance(account, (err, result) => {
if (err) {
return reject(err);
}
resolve(result.toNumber());
});
});
module.exports = (deployer, network, accounts) => {
return checkBalance(accounts[0])
.then(accountBalance => {
console.log('Current account balance', accountBalance);
return Promise.resolve();
})
.then(_ => deployer.deploy(Migrations))
.catch(err => throw err);
};
So to clarify @kostysh , you can't use any synchronous methods with truffle-hd-wallet as the provider? I've found such and have used ether.js for my provider and wallets instead.
@kostysh it did not work for me.
it cause an error
1_initial-migration.js:25.catch <br> (err => throw err); <br> ^^^^^
@kostysh it did not work for me. it cause an error
1_initial-migration.js:25.catch <br> (err => throw err); <br> ^^^^^
This solution is working fine in my project. Please show your code or send a link to your repo.
I was having this error when trying to access web3.eth.accounts and deploying to ropsten:
Error: Web3ProviderEngine does not support synchronous requests.
I was able to solve this by passing in the function to module.exports in 2_deploy_contracts.js as such:
module.exports = function(deployer, network, accounts) {
// access accounts through the accounts parameter which is an array
let owner = accounts[0]
...
// call deployer.deploy() here
}
So I essentially don't even have to think about promises and callbacks if I just use accounts that was passed in as a parameter to the function that deploys the contract.
Hope this helps.
So I essentially don't even have to think about promises and callbacks if I just use accounts that was passed in as a parameter to the function that deploys the contract.
You cannot check the balance of the selected account in a synchronous manner. It is possible using promises (or callbacks) only. So I do not understand your comment, please read the history of an issue carefully.
Oh, I thought the issue was problems deploying to test networks using truffle-hdwallet-provider. My comment was how I was able to do so.
I had this same issue. It turned out I had the following line in my package.json
:
"truffle-hdwallet-provider": "0.0.6",
but now it is included as a sub-package inside truffle with the current version:
"truffle-hdwallet-provider": "1.0.6",
That fixed it for me.
Had this issue today, was fixed when I used specific truffle and truffle-hdwallet-provider versions:
"truffle": "5.0.8",
"truffle-hdwallet-provider": "1.0.5"
Yeah, reinstalling truffle-hdwallet-provider worked for me! Thanks using v 1.0.15
does not try to change a gas limit
You maybe using the old repo.
Try the below
npm install @truffle/hdwallet-provider
and replace with
const HDWalletProvider = require("@truffle/hdwallet-provider");
instead of truffle-hdwallet-provider-privkey
I see this error being reported here: https://github.com/MetaMask/provider-engine/issues/178, but I don't see people have this issue with the HDWalletProvider.
Please advise