I am creating my first Dapp by using web3 1.0.0-beta.37 and trufflfe

While getting the accounts in app.js by using ganache-CLI and Metamask, I am getting following error.

Uncaught TypeError: e is not a function in the console 

Following is my code of App.js

import React, { Component } from 'react';
import './App.css';
import FormSubmitContract from './contracts/FormSubmit.json';
import getWeb3 from './utils/getWeb3.js';

class App extends Component {
  state = {

 componentDidMount = async () =>{
    const web3 = await getWeb3();
    const accounts = await web3.eth.getAccounts();
    const networkId = await web3.eth.net.getId();
    const deployedNetwork = FormSubmitContract.networks[networkId];
    const  instance = new web3.eth.contract(FormSubmitContract.abi, 
    deployedNetwork, deployedNetwork.address);

I am able to print the web3 in console log

Proxy {_requestManager: s, currentProvider: MetamaskInpageProvider, eth: r, db: e.exports, shh: a, …}

But got undefined in

const accounts = await web3.eth.getAccounts();
console.log(accounts); ==> undefined

I think there has been change in web3 1+ versions for getting the accounts.

Help me. Thanks in advance

2 Answers 2


In Metamask, go to Setting -> Privacy & Security -> deactive the "Privacy Mode" option.

If you want to use the Privacy Mode then you have to modify your code



Couple of things to experiment with:

  1. Try using web3 1.0.0-beta.35
  2. Are you calling window.ethereum.enable() to unlock the selected user account?
   const { ethereum } = window
   if (ethereum) {
      try {
        const web3 = new Web3(ethereum)
        const selectedAccount = await ethereum.enable()
        if (!selectedAccount) {
          // User didn't give permission for dapp to access wallet
          console.log('User opted out')
        } else {
          // User allowed access
          console.log('user gave access!')
        return web3
      } catch (error) {
        // whoopsie!

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.