Search code examples
ethereumsolidityweb3js

web3 getAccounts doesn't get resolved


web3.eth.getAccounts() is not working for me. The code below shows "error" on execution (gets rejected). I am using web3 1.0.0 beta-46. I am learning from Stephen Grider's tutorial videos and he used beta-26, is it version related issue or am i doing something wrong?

const assert = require('assert');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());

web3.eth.getAccounts()
    .then(fetchedAccounts => {
      console.log(fetchedAccounts);
    },() => {
      console.log("error");
    });

Solution

  • Haven't tried it myself but this seems to be a bug with the latest versions of web3. Try with 1.0.0 beta-37.