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.
Parameters
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 & Stacks testnetRegtest
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);
}
β
changeNetwork Result
The method will
prompt the user to switch their Xverse wallet to the network your app specified.
return
null
if the user accepts to switch their wallet to the new network -> Null response
The account switch in the wallet will emit a networkChange event which your app can catch.
Last updated