🇺🇲
Broearn Wallet Documentation
  • 🧬OVERVIEW
    • 💡What is Broearn Wallet?
    • 🛡️Security
    • 📋Available Networks
      • Parallel Universe Chain
      • Bitcoin
      • Ethereum
      • BNB Chain
      • Tron
      • Solana
      • OKX Chain
      • Optimism
      • Fantom
      • Ethereum Classic
      • Polygon
      • Avalanche
  • 🛸PUT
    • Extension & in Broearn app
      • Events
        • Disconnect
        • Accounts Changed
    • Detecting the Provider
  • Establishing a Connection
  • PROVIDER METHODS
    • Connect
    • Disconnect
    • SignMessage
    • SignTransaction
    • SignAllTransactions
    • SignAndSendTransaction
  • 🔹ETHEREUM & EVM
    • Getting Started with Ethereum and EVM
    • Detecting the Provider
    • Establishing a Connection
    • Sending a Transaction
    • Signing a Message
    • Provider API Reference
      • Properties
        • eth_chainId
        • eth_networkVersion
        • eth_selectedAddress
        • _events
        • _eventsCount
      • Events
        • Connect
        • Accounts Changed
        • Disconnect
        • Chain Changed
      • Methods
        • isConnected
        • request
  • Demo Applications
  • 📜ERRORS
  • ADVANCED
    • Auth
      • Web Javascript demo
      • Web Java
      • Web Golang
      • Web PHP
  • COMMUNITY AND SUPPORT
    • 🐦Twitter
    • ✈️Telegram
    • 🎮Discord
Powered by GitBook
On this page
  1. ETHEREUM & EVM
  2. Provider API Reference
  3. Events

Accounts Changed

Event emitted upon changing accounts within your Broearn wallet.

window.ethereum.on('accountsChanged', (newAccounts: String[]) => {
      // "newAccounts" will always be an array, but it can be empty.      
      if (newAccounts) {
        console.log(`switched to new account: ${newAccounts}`);
        accounts = newAccounts;
      } else {
        /**
         * In this case dApps could...
         *
         * 1. Not do anything
         * 2. Only re-connect to the new account if it is trusted
         *
         * ```
         * provider.send('eth_requestAccounts', []).catch((err) => {
         *  // fail silently
         * });
         * ```
         *
         * 3. Always attempt to reconnect
         */
  }
})
PreviousConnectNextDisconnect

Last updated 1 year ago

🔹