JincorTech / ico

Jincor ICO smart-contracts
80 stars 30 forks source link

Deployment Error Web3ProviderEngine does not support synchronous requests #69

Open codingmalkio opened 6 years ago

codingmalkio commented 6 years ago

Hi guys forgive me by asking but I tried to deploy/migrate the smart contract on ropsten network but its throwing an error.

node:20033) UnhandledPromiseRejectionWarning: Error: Web3ProviderEngine does not support synchronous requests. at ProviderError.ExtendableError (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:9328:17) at new ProviderError (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:314009:24) at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:314133:17 at HDWalletProvider.send (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:314171:22) at Object.send (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:175476:31) at RequestManager.send (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:331128:32) at Eth.get [as accounts] (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:43421:62) at web3.eth.getAccounts (/Users/krispymallows/Dropbox/Server/Workspaces/ico/migrations/3_deploy_ico_contract.js:33:82) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) (node:20033) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:20033) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I tracked it down to this line right here on: /migrations/3_deploy_ico_contract.js: line 28

const icoInstance = web3.eth.contract(JincorTokenICO.abi).at(JincorTokenICO.address);
icoInstance.setEthPriceProvider(EthPriceProvider.address, { from: web3.eth.accounts[0] });

here's my Truffle.js

var mnemonic = "acoustic renew ..."; 

module.exports = {
   solc: {
        optimizer: {
            enabled: true,
            runs: 200
        }
    },
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*" // Match any network id
    },
    ropsten: {
      provider: function() {
        return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/.....", 0)
      }, 
      gas:4698712,
      network_id: 3, 
      from:'0x7fb84cae8dd852c8471ab.....',
      gasPrice:100000000000, 
   },

  },
};

Here's how I start the oracle bridge ethereum-bridge -H https://ropsten.infura.io/.... --broadcast -a 0

I am running out of ideas, can you help me and point out where I might have went wrong?

Truffle v4.0.1 (core: 4.0.1) Solidity v0.4.18 (solc-js) node v8.11.2

UPDATE: its this line afterall that's been causing the error Error Web3ProviderEngine does not support synchronous requests

const icoInstance = web3.eth.contract(JincorTokenICO.abi).at(JincorTokenICO.address);
hlogeon commented 6 years ago

Hello! Do you use docker to deploy the contracts? How did you try to deploy your contracts?

codingmalkio commented 6 years ago

Thank you for taking the time. I was trying to deploy it on infura ropsten testnet. as seen on Jincor ICO dashboard's .env.test https://github.com/secret-tech/backend-ico-dashboard/blob/develop/.env.test

Working:

Not Working:

I ran into the said error message with call to account number and block number

migrations/2_deploy_contracts.js const beneficiary = web3.eth.accounts[0]; const startBlock = web3.eth.blockNumber; const endBlock = web3.eth.blockNumber + 100; deployer.deploy(JincorTokenPreSale, hardCap, softCap, token, beneficiary, totalTokens, 255, limit, startBlock, endBlock);

I refactored the code into async

web3.eth.getBlockNumber((err, blockNumber) => {
      web3.eth.getAccounts((err,accounts)=>{
         const startBlock = blockNumber;
          const endBlock = blockNumber + 100;
         const beneficiary = accounts[0];
         deployer.deploy(JincorTokenPreSale, hardCap, softCap, token, beneficiary, totalTokens, 255, limit, startBlock, endBlock);
      });
   });

But I do not know the async equivalent of

icoInstance.setEthPriceProvider(EthPriceProvider.address, { from: web3.eth.accounts[0] });
EthPriceProvider.setWatcher(JincorTokenICO.address, { from: web3.eth.accounts[0] });
BtcPriceProvider.setWatcher(JincorTokenICO.address, { from: web3.eth.accounts[0] });
EthPriceProvider.startUpdate(30000, { value: web3.toWei(1000), from: web3.eth.accounts[0], gas: 200000 });
BtcPriceProvider.startUpdate(650000, { value: web3.toWei(1000), from: web3.eth.accounts[0], gas: 200000 });

on migrations/3_deploy_ico_contract.js

prepending async keyword/adding then statements doesn't seem to help

I hope you can point me to the right direction thanks