Closed arcticmatt closed 9 months ago
@arcticmatt Hi!! how are you ? do you found a way to handle these event ? thank you
For account events, you can use "accountChanged". Notice it is "account" and not "accounts". Now for the chain or cluster, I can't find anything. Phantom team should look into adding an event for us. As of right now, you'd almost have to make an interval that checks that network every so often and emit your own event. Mostly every connector has this feature, so it's odd it isn't available for us. The apps right now will have no idea that the user has changed from mainnet to devnet or vise-versa, and will need to check it before interacting with the wallet every time, which is lousy.
It would be useful to be able to listen for these events in the frontend, e.g. so you can do something when someone changes their account in Phantom.
MetaMask has support for
accountsChanged
https://docs.metamask.io/guide/ethereum-provider.html#events