0

Below is my migration file,

var startTime = web3.eth.getBlock(web3.eth.blockNumber((err, res) => {})).timestamp + 30;
var endTime = startTime + 4 * 60 * 60;
var presaleLimit = startTime + 1 * 60 * 60;
var crowd1Limit = startTime + 1.45 * 60 * 60;
var crowd2Limit = startTime + 2.30 * 60 * 60;
var crowd3Limit = startTime + 3.15 * 60 * 60;
var disc1 = web3.toWei('1', 'ether');
var disc2 = web3.toWei('2', 'ether');
var rate = 3;
var wallet = '0x58B219a8Fd3897303D3C106031736df26Ad3A406';
module.exports = function(deployer) {
  deployer.deploy(SetherCrowdsale, startTime, endTime, rate, wallet, presaleLimit, crowd1Limit, crowd2Limit, crowd3Limit, disc1, disc2);
};

I am getting the below error while trying to run this on ropsten.

Running migration: 2_deploy_contracts.js

/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-error/index.js:10
  this.stack = (new Error(message)).stack;
^
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:219413
        throw error;
        ^

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 /home/fkp/Desktop/BCW/migrations/2_deploy_contracts.js:3:44
    at Script.runInContext (vm.js:74:29)
    at Script.runInNewContext (vm.js:80:15)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-require/require.js:97:1
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:532:3)

1 Answer 1

1

I think the problem is in this line:

var startTime = web3.eth.getBlock(web3.eth.blockNumber((err, res) => {})).timestamp + 30;

basically you're mixing sync and async functions. You're calling getBlock synchronously but blockNumber asynchronously.

This should work properly:

var startTime = web3.eth.getBlock(web3.eth.blockNumber).timestamp + 30;
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.