--- title: eth_requestAccounts description: 连接钱包 --- --- ### 参数 - 该方法不接受任何参数 --- ### 返回值 -
AddressListarray
--- ### Request ```js async function connectWallet() { if (window.ethereum) { try { const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' }); console.log('钱包连接成功',accounts); } catch (error) { console.error('用户拒绝了连接请求', error); } } else { console.error('请安装 MetaMask 钱包'); } } ```