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?
Best Answer
try this!!