我在试图获得核心钱包账户时出错了。当我重新加载页面时会发生这种情况。它应该检测到帐户,但它不是。我用的是web3modal和以太。我也使用核心钱包雪崩富士测试网络。
下面是控制台的样子:
这是我的支票帐户代码:
const updateCurrentWalletAddress = async () => {
const accounts = await window?.ethereum?.request({
method: "eth_requestAccounts"
}).catch((err)=>{
console.log(err)})
if(accounts){
setWalletAddress(accounts[0])
}
}
下面是用于检查的useEffect钩子:
useEffect(() => {
updateCurrentWalletAddress()
window?.ethereum?.on("accountsChanged", updateCurrentWalletAddress)
}, []);
我试着清除浏览器数据、缓存和cookie。我试着创建了一个新账户。我试过卸载核心钱包。
发布于 2022-11-05 10:15:02
方法名应该是eth_accounts
而不是eth_requestAccounts
。这解决了我的问题。
https://stackoverflow.com/questions/74326582
复制相似问题