参考: https://learnblockchain.cn/article/3675
/**
* @description: Switch to the rest of the network (mainly used)
* @param {*} findChain
* @return {*}
*/
async function switchToOtherNetwork(findChain) {
const data = [];
data.push(findChain);
console.log(findChain, "switchNetwork");
try {
await window.ethereum.request({
method: "wallet_addEthereumChain",
params: data // [{XXXXX}] is Array
});
} catch (error) {
console.log(error);
}
}