The OneKey Browser Extension provider implements the Node.js EventEmitter API.

This sections details the events emitted via that API.

There are innumerable EventEmitter guides elsewhere, but you can listen for events like this:


When switching accounts.

window.nostr.on('accountsChanged', (accounts) => {  
    // Handle the new accounts, or lack thereof.
    // "accounts" will always be an array, but it can be empty.

chainChanged (Deprecated)

When the chain changes.

window.nostr.on('chainChanged', (chainId) => {  
    // Handle the new chain.  
    // Correctly handling chain changes can be complicated.  
    // We recommend reloading the page unless you have good reason not to.  window.location.reload();

Last updated