How do you detect when a MetaMask user disconnects their wallet from your dapp? I see there is a disconnect event, but this is a for disconnecting from RPC - I want to know when the user has explicitly disconnected their wallet.


Use the accountschanged event.

ethereum.on('accountsChanged', handler: (accounts: Array<string>) => void);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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