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
  • Switch the active network in the user's Xverse wallet
  • Parameters
  • changeNetwork Result
  1. Wallet Methods

wallet_changeNetwork

Switch the selected network within the wallet.

Previouswallet_getNetworkNextXverse Custom Methods

Last updated 1 month ago

Switch the active network in the user's Xverse wallet

The wallet_changeNetwork method allows your DApp to prompt the user's wallet to switch between different blockchain networks. This feature is essential for workflows that require switching networks, such as bridging assets between different chains or testing features on testnets.

The app must have first and obtained

You can fetch the networks that the user's wallet is currently connected to, using .

Parameters

Request parameters
Description

name

a string representing the network the wallet should switch to. This is a required parameter and should be one of the supported network names:

  • Mainnet for Bitcoin & Stacks mainnet

  • Testnet for Bitcoin & Stacks testnet

  • Signet for Bitcoin Signet & Stacks testnet

  • Regtest for Bitcoin Regtest & Stacks testnet

import Wallet from 'sats-connect';

async function example() {
  const res = await Wallet.request('wallet_changeNetwork', {
    name: 'Signet'
  });
  if (res.status === 'error') {
    console.error(res.error);
    return;
  }

  console.log(res.result);
}

Null response

This method returns null if the active chain is switched.

changeNetwork Result

The account switch will emit a event which your app can catch.

Your app can then fetch the user's active Xverse account under the new network with the method.

 enum BitcoinNetworkType {
  Mainnet = 'Mainnet',
  Testnet = 'Testnet',
  Testnet4 = 'Testnet4',
  Signet = 'Signet',
  Regtest = 'Regtest',
}
✅
connected to the wallet
account read permissions.
wallet_getNetwork
wallet_getAccount
networkChange