I'm using the next function to get the first account from user's MetaMask:
var account = web3.eth.getAccounts((error,result) => {
if (error) {
console.log(error);
} else {
return result[0];
}
});
However the user could have selected any other account from his MM not just the first one, or switch the account anytime. How to get the current selected account?
web3.eth.getAccounts()as stated in my question. However the first element in the result is not the selected user account, it's just the first account in MM – Veilkrand Jan 17 '20 at 06:54