我是 web3 学习的新手,我试图在用户使用他们的 crpto 钱包进行身份验证时获取用户的帐户地址。为此,我使用了以下代码(我从谷歌获得),它在桌面浏览器上工作正常但在移动设备上不起作用甚至我已经在手机上安装了 metamask 应用程序。这是我的代码
<script>
document.getElementById('walletconnectBtnHere').addEventListener('click', event => {
let accountsOnEnable = await ethereum.request({ method: "eth_accounts" });
let address = accountsOnEnable[0];
address = address.toLowerCase();
alert("Address: " + address);
});
<script>`
<button id="walletconnectBtnHere">Connect Wallet<button/>`
在手机上调用钱包功能只能在 MetaMask 内置浏览器中使用。前往 MM 应用程序,并使用其内部浏览器。