I am unable to disconnect from Metamask account. I am attaching the code snippet.
export const logoutUser = () => {
if (window.ethereum && window.ethereum.isMetaMask) {
window.ethereum.on('accountsChanged', function (accounts) {
return () => window.ethereum.removeListener('accountsChanged', accounts);
});
}
}
As of now, you cannot log out of Metamask by web3 or Ethereum api. You have to manually disconnect Metamask.
accountChanged
listener will just detect if Metamask connects to a different account.