0
const deploy = async () => {
  const accounts = await web3.eth.getAccounts();
  console.log("Attempting to deploy from contract ", accounts);
};

The code runs but returns nothing and even the next line doesn't get logged to the console. I am using HDWalletProvider v1.0 and using Infura rinkeby test network and when I tried to log the provider used, it returned the correct object with my account and everything.

4
  • web3.eth.getAccounts() returns a list of accounts which are unlocked on the node that you're connected to. So when connected a public node, this function should return an empty list, I would say, pretty much by definition (or would you like to be able to unlock your account on a public node?). Apr 6 '20 at 17:21
  • @goodvibration It's a problem with requests sent through web3 in general whether it's getAccounts or deploy. The terminal doesn't wait for the response it terminates at the line of the request and runs no code after that line. I don't know why this is happening, I am waiting for the response and all. Apr 6 '20 at 18:19
  • You're probably calling deploy without resolving the promise that it returns (for example, by awaiting for it to complete). You can do that safely only if it's the last line in your script. Apr 6 '20 at 18:52
  • I'm having issues with this as well with truffle. const accounts = await this.eth.getAccounts() ... no execution after that, can't log anything... I might as well called process.exit()
    – flcoder
    Mar 7 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.