0

I have a node in ropsten network and created 3 accounts say a,b,c using geth. Connected metamask with ropsten network and created other account 'd' using metamask and imported accounts a,b and c by passing JSON file. But account 'd' was not shown with eth.accounts in geth console.

When I connected metmask with nodejs by :

var Web3 = require('web3');

window.addEventListener('load', function() {

window.web3 = new Web3(web3.currentProvider)

  var ETH_CLIENT = window.web3
  web3.eth.getAccounts(function(error, accounts) {
  if (error) {
  console.log(error);
  }


console.log('account0 ='+accounts[0]);

console.log('account1 = '+accounts[1]); 
});
})

accounts[0] shows account address of 'd'. accounts[1] is 'undefined'.

How to get imported accounts from metamask in nodejs?

And why account 'd' is not visible with command 'eth.accounts' in geth console? I have a running ropsten node at port 8545. But accounts 'a' ,'b' and'c' was not visible in metamask when I connected it. I had to import accounts..

Help will be appreciated :)

1 Answer 1

2

The accounts array is going to be always of length 1 and contain the account selected in metamask

2
  • And why account 'd' is not visible with command 'eth.accounts' in geth console? I have a running ropsten node at port 8545. But accounts 'a' ,'b' and'c' was not visible in metamask when I connected it. I had to import accounts..
    – angelmaria
    May 23, 2018 at 9:57
  • Honestly I don't know
    – user38075
    May 23, 2018 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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