wallet_changeNetwork

Switch the selected network within the wallet.

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 connected to the wallet and obtained account read permissions.

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

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:

 enum BitcoinNetworkType {
  Mainnet = 'Mainnet',
  Testnet = 'Testnet',
  Testnet4 = 'Testnet4',
  Signet = 'Signet',
  Regtest = 'Regtest',
}
  • Mainnet for Bitcoin & Stacks mainnet

  • Testnet for Bitcoin & Stacks testnet

  • Signet for Bitcoin Signet

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);
}

changeNetwork Result

Null response

This method returns null if the active chain is switched.

Last updated