Events
pub(accounts.subscribe)
Fires when the user adds or removes accounts, or switches the active chain (genesisHash) in the extension.
Callback Payload
[
{
address: string;
name: string;
type: "sr25519" | "ed25519" | "ecdsa";
genesisHash?: string;
}
]
Example
provider.accounts.subscribe((updatedAccounts) => {
console.log('Account list changed:', updatedAccounts);
});
pub(accounts.subscribeV2)
V2 version of the accounts subscription with the same payload structure as pub(accounts.subscribe).
pub(accounts.unsubscribe)
Unsubscribes a previously registered account change listener.
Example
const unsubscribe = provider.accounts.subscribe(callback);
// later...
unsubscribe();