I'm building an Angular app which connects to various blockchain accounts through metamask. One of my services connects to MetaMask by obtaining a provider and signer using
this.myProvider = new ethers.providers.Web3Provider(window.ethereum); this.mySigner = this.myProvider.getSigner();
I would like my service to be aware when the user switches accounts or chains, or signs out of metamask and I am trying to find a way to be informed of those events when they happen.
I see that the object returned to
myProvider is a Web3Provider, which contains an
addListener method which takes 2 parameters, an
EventType and a
Listener but I can't find any documentation on how to access valid Event Types or how to set up a listener I assume that these events might provide what I am looking for. Can somebody point me to an example of how to use these events and listeners?