Closed Jack-Works closed 2 days ago
@danfinlay Many thx
Were you able to figure this out? Per the readme, you should be able to subscribe to events by constructing an ethereum
provider like this:
const createMetaMaskProvider = require('metamask-extension-provider')
const provider = createMetaMaskProvider()
provider.on('accountsChanged', (accounts) => {
})
Hi, I am trying to use the event listener "accountsChanged" as @danfinlay mentioned, but I'm not able to receive any events. I am subscribing to events by constructing an Ethereum provider like above in the frontend portion of my extension. Would you have any clue as to why the event might not be firing?
Main goal of this is to ensure my own extension is updated to using the currently selected account address on Metamask
There are only four events (error,message,connect,disconnect)now, really hope you can add all evtnts to 'metamask-extension-provider'
https://docs.metamask.io/guide/ethereum-provider.html#accountschanged
But there is no
ethereum
object injected by MetaMask in the extension environment, how can I receive this kind of event?