Web3 Vue3连接MetaMask(小狐狸)钱包Request of type ‘wallet_requestPermissions‘ already pending for origin过程记录
"Request of type 'wallet_requestPermissions' already pending for origin http://localhost:5173. Please wait."报错解决,window.ethereum冒红解决,以及Vue3连接MetaMask小狐狸钱包的步骤
·
下载web3依赖
yarn add web3
连接申请
window.ethereum.request({ method: 'eth_requestAccounts' }).then((res: any) => {
console.log(res, '这就是小狐狸地址')
}).catch((err: any) => {
console.log('44',err)
if (err.code===-32002) {
// 用户在申请连接时既没有取消也没有同意钱包的绑定需要手动打开小狐狸钱包的插件进行绑定
}
if (err.code == 4001) {
console.log('用户拒绝连接')
}
})
ethereum冒红

在vite-env.d.ts文件中加入
declare interface Window{
ethereum:any
}

冒红消失
连接时报错
code :-32002
“Request of type ‘wallet_requestPermissions’ already pending for origin http://localhost:5173. Please wait.”
目前了解到的方法:需要手动进行点击插件进行管理钱包连接

取消后再申请
成功
更多推荐




所有评论(0)