const deploy = async () => {  
    **var acct = await web3.eth.getAccounts();**  
    console.log("ac", acct);  

even the console is not getting printed,what could be the reason?
any possible solution would be grateful.


From new updates, now you have to request access of accounts by using method await ethereum.enable(); before getAccounts.For, more details check : this

  • thanks for the information it cleared my most of the doubts,but i am not getting the part how can i use 'window' variable in the code since it is part of the browser. i am getting the error as window is not defined. – arun Feb 25 '19 at 12:06
  • window.web3 only injected by metamask when you are viewing the page with HTTP and https protocol. So if you are viewing the page as a blank page or local page(file://), their won't be a web3 object in window scope. – Mahesh Rajput Feb 25 '19 at 12:14
  • I am not getting the above suggested solution.I have enabled privacy mode in metamask so how can i integrate it with the below code to get the accounts. below is my code const HDWalletProvider = require('truffle-hdwallet-provider'); const Web3 = require('web3'); const mnemonic = 'paraphrase' const web3 = new Web3(new HDWalletProvider( mnemonic, 'rinkeby.infura.io/v3/'mytoken', )); const deploy = async () => { const accounts = await web3.eth.getAccounts(); console.log("accounts", accounts); } deploy(); – arun Feb 26 '19 at 6:32

Your Answer

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

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