Skip to main content
You can listen to events emitted by the wallet provider by using the onWalletProviderEvent. It will return an unsubscribe function that you can call to stop listening to the event.

Usage

import { onWalletProviderEvent } from '@dynamic-labs-sdk/client';

const unsubscribe = onWalletProviderEvent({
  callback: ({ addresses }) => {
    console.log('Accounts changed event was called with', addresses);
  },
  event: 'accountsChanged',
  walletProviderKey: 'metamaskevm',
});

// Call unsubscribe() when you no longer need the listener

Available events

  • accountsChanged: (params: { addresses: string[] }) => void;
  • disconnected: () => void;
  • networkChanged: (params: { networkId: string }) => void;