Metamask: How to change the network configuration by code
参考:https://patricio-lopez-75857.medium.com/metamask-how-to-change-the-network-configuration-by-code-21f25d04d932
进入console,把下面的代码放进就可以了,如果出现报错就把第二行window.web3 = new Web3(window.ethereum)删除,就会自动连接fuji网络,选择用户,因为已经创建了很多测试账户。
if(window.ethereum) { window.web3 = new Web3(window.ethereum) window.ethereum.request({method: 'eth_requestAccounts'})//这一行是自动连接钱包 window.ethereum.request({ method: 'wallet_addEthereumChain', params: [{chainId: '0xa869', chainName: "Fuji Testnet", nativeCurrency: { name: "AVAX", symbol: "AVAX", decimals: 18 }, rpcUrls: ['https://api.avax-test.network/ext/bc/C/rpc'], blockExplorerUrls: ['https://cchain.explorer.avax-test.network/'] }] }) }

