CRYPTO NEWS

How to inform the user an account isn’t active after disconnecting the currently active account in MetaMask?

Scenario…

  • User has connected two accounts to our DAPP via MetaMask.
  • User disconnects the currently active account.
  • User still has their other connected account but it isn’t active in MetaMask.

In our DAPP we’re listening for changes like this.

useEffect(() => {   if (!window.ethereum) return;    const onAccountsChange = (connectedAddresses) => {     props.setActiveAddress(connectedAddresses[0]);   };    window.ethereum.on('accountsChanged', onAccountsChange);    return () => {     window.ethereum.off('accountsChanged', onAccountsChange);   }; }, []); 

This works great for switching accounts, but in the scenario above, it will setActiveAddress to the other connected account even though it isn’t actually active in MetaMask.

dapp

In our DAPP we’d like to tell the user "Please open MetaMask and activate " to remove a small layer of possible confusion.

Is this possible?

How to inform the user an account isn’t active after disconnecting the currently active account in MetaMask?

Shopping cart
There are no products in the cart!
Continue shopping
0