Sats Connect - Wallet API for Bitcoin & Stacks
  • Introduction
  • Wallet Providers
    • getInfo
    • getProviders & getProviderById
  • Connecting to the wallet
    • Connect to Xverse Wallet
    • Disconnect from Xverse Wallet
    • Connect to other wallets
      • Manage a user's default wallet
    • [Legacy âš ī¸] getAccounts
  • Wallet Methods
    • request methods
    • wallet_getAccount
    • wallet_getNetwork
    • wallet_changeNetwork
    • Xverse Custom Methods
  • Xverse Wallet Permissions
  • Xverse Wallet events
  • BITCOIN METHODS
    • 🟠getAddresses
    • 🟠signMessage
    • 🟠signPsbt
    • 🟠sendTransfer
    • 🟠signMultipleTransactions
    • 🟠getBalance
    • 🎨createInscription
    • 🎨createRepeatInscriptions
    • 🎨ord_getInscriptions
    • 🎨ord_sendInscriptions
    • 🔲runes_getBalance
    • 🔲runes_transfer
    • 🔲Mint Runes
      • runes_estimateMint
      • runes_mint
    • 🔲Etch Runes
      • runes_estimateEtch
      • runes_etch
    • 🔲runes_getOrder
    • 🔲Speed up a Rune Mint or Etch order
      • 🔲runes_estimateRbfOrder
      • 🔲runes_rbfOrder
  • STACKS METHODS
    • 🔴stx_getAccounts
    • 🔴stx_signMessage
    • 🔴stx_signStructuredMessage
    • 🔴stx_transferStx
    • 🔴stx_signTransaction
    • 🔴stx_callContract
    • 🔴stx_deployContract
  • GUIDES
    • Verify Bitcoin message signatures
    • Creating Bitcoin PSBTs
    • 📱Mobile Integration
    • Next.js support
  • RESOURCES
    • App Template
    • Demo App
    • Changelog
    • Github Issues
    • Developer forum
    • BIP322
Powered by GitBook
On this page
  • Listen to wallet events
  • accountChange event
  • accountDisconnected event
  • networkChange event

Xverse Wallet events

How apps can respond to user actions using wallet events

PreviousXverse Wallet PermissionsNextgetAddresses

Last updated 1 month ago

Sats Connect lets your app listen to key Xverse wallet events to provide a smooth user experience when your users change accounts or networks, or disconnect their account from your app.

Xverse wallet will emit dedicated events that your app can use to update the UI or request new permissions when required.

Listen to wallet events

To be notified of events, apps need to first to receive Listeners registered using Wallet.addListener() will be notified of events for authorised accounts.

const removeListener = Wallet.addListener('accountChange', (event) => {
  console.log('The account has changed.', event);

  exampleUpdateUi();
  exampleRequestPermissionsForCurrentAccount();
});

// When no longer needed, the listener can be removed by calling the function
// returned by `addListener`.
removeListener();

The addListener method is typed to include all currently available events. They currently include:

  • accountChange

  • accountDisconnected

  • networkChange

accountChange event

the accountChange event is emitted when your connected user switches their Xverse wallet to another account.

The event will pass the below event payload object to a listener callback:

Property
Description

type

the event type -> "accountChange"

addresses

accountDisconnected event

The event will pass the below event payload object to a listener callback:

Property
Description

type

the event type -> "accountDisconnected"

networkChange event

the networkChange event is emitted when when your user switches between the Mainnet, Testnet & Signet networks in their Xverse wallet.

The event will pass the below event payload object to a listener callback:

Property
Description

type

the event type: "networkChange"

bitcoin

the name of the Bitcoin network the user has just switched to: Mainnet, Testnet, Signet or Regtest Example: {"name": "Signet"}

stacks

the name of the Stacks network the user has just switched to: Mainnet or Testnet Example: {"name": "Testnet"}

addresses

The array of address objects for the new account the user has switched to. -> See for the detailed format.

â„šī¸ This will only be returned if your app is to the new account the user has switched to, and already has on the new account's data. Your app can request to connect to the new account if required.

the accountDisconnected event is emitted when when your user revokes the connection with your app from their Xverse wallet, or when your app .

The array of address objects for the connected account on the new network the user has switched to. -> See for the detailed format. â„šī¸ This will only be returned if your app is to the new account the user has switched to, and already has on the new account's data. Your app can request to connect to the new account if required.

connect to the wallet
account read permissions.
renounces its wallet permissions
getAccount
connected
read permission
getAccount
connected
read permission