Browser Extension

Events

React to connection, account and network changes in the Joey browser extension.

const off = joey.on('accountsChanged', (accounts) => setAccount(accounts[0]?.address ?? null))
joey.on('networkChanged', (network) => setNetwork(network))
joey.on('connect', ({ accounts, chain }) => {})
joey.on('disconnect', () => setAccount(null))

off() // or joey.off('accountsChanged', listener)
Event Payload Sent when
connect { accounts: JoeyAccount[], chain: JoeyChain | null } Your site is granted access for the first time. Reconnecting an already-approved site sends nothing.
accountsChanged JoeyAccount[] (empty when access is revoked) The accounts your site can use change. Each site only ever sees its own granted accounts.
networkChanged JoeyNetwork | null The user switches network in Joey.
disconnect { reason?: string } Your site's access ends (see below).

When disconnect is sent

  • Your dApp called disconnect(). Other tabs and frames of your origin are told too.
  • The user removed your site under Settings → Connected Sites.
  • The user deleted every account your site had access to.
  • The user reset the wallet.

Locking Joey does not disconnect your site. Requests made while Joey is locked wait behind the unlock screen.

Delivery rules

  • Events only go to sites that hold a grant. A site the user never approved receives nothing.
  • Registering the same listener twice creates two subscriptions; remove each one separately.

Wallet Standard

If you use Joey through a Wallet Standard adapter, standard:events emits change with { accounts } when the account set changes.