I have been following a tutorial on creating solidity contracts. I am unable to get the list of account numbers on my metamask wallet when I use my script below.

  async componentWillMount(){
    await this.loadWeb3()
    await this.loadBlockChainData()

//connect to metamask and reads it into the app using web3
  async loadWeb3() {
    if (window.etheruem) {
      window.web3 = new Web3(window.etheruem)
      await window.etheruem.enable()
    else if (window.web3) {
      window.web3 = new Web3(window.web3.currentProvider)
    else {
      window.alert('Non etheruem browser detected. You should consider trying to install metamask')

  async loadBlockChainData() {

    const web3 = window.web3
    //load account from metamask
    const accounts = await web3.eth.getAccounts()


I should be getting a list of account numbers but the code above prints "[]" instead.

My research indicates that the connection issues might be due to privacy settings. So I tried to disable my privacy settings to allow incoming connections. But I think that option to disable privacy settings has been removed in the later metamask updates.

privacy settings

I have also tried to change my network to the Ganache address (instead of the main etheruem network) and successfully got testing accounts balances on Ganache reflected on metamask, but I am still not getting the accounts printed on my web console. It continues to prints a "[]"

Changing network to ganache url

I also tried adding my local server address to the list of sites that are allowed to connect to my metamask. (although wasn't advised by the tutorial) But this also doesn't seem to work.

Added my server to list of connected sites

I also found a recent question similar to mine, but the issue was different (I believe) since I am running my application on a local server instead of just a page.

Please let me know if anyone has any suggestions on how to fix this.

Thank you

2 Answers 2


There is typo in your code. Replace:

window.web3 = new Web3(window.etheruem)


window.web3 = new Web3(window.ethereum)

Also if your connection between metamask and the local project is set properly you should be able to access the current account by using ethereum.selectedAddress.


Try this, the 2 .on event handlers are helpfull for working with later.


  window.ethereum.on("accountsChanged", accounts => {
    // handle what happens when acounts change
  window.ethereum.on('chainChanged', () => {
    // handle what happens when chain changes, prefereably reload the page

  await window.ethereum.request({ method: "eth_requestAccounts" })
  .then(accounts => 
      // loop the accounts. 

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.