0

I've been using web3 v 0.20 and I recently noticed that getting accounts from

  web3.eth.getAccounts(function(error, accounts) {

returns undefined.

Is Metamask 7.2.1 forcing it to be undefined for getting accounts now? It used to be okay last week though :(

enter image description here

  • In web3 v1.x, this function takes only one parameter, which is equivalent to your second parameter (accounts). Therefore, if you were calling it as shown in your question but under web3 v1.x, the second parameter would be undefined. I therefore conclude with a high degree of confidence that you are under web3 v1.x (and not under web3 v0.20.x as you think). – goodvibration Sep 26 at 18:30
  • @goodvibration nah, see my update. – bbusdriver Sep 26 at 18:39
  • You wrote "returns undefined" at the top of your question, so please make up your mind ([] != undefined). – goodvibration Sep 26 at 18:48
  • @goodvibration apologies.. I got undefined from the try/catch. So any idea why accounts is empty please – bbusdriver Sep 26 at 18:52
  • Sure, non of your accounts is unlocked on the node that you're communicating with. – goodvibration Sep 26 at 18:54

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.