web3 钱包连接在桌面浏览器上工作正常但在移动浏览器上不工作

问题描述 投票:0回答:1

我是 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/>`
javascript blockchain web3js web3modal
1个回答
0
投票

在手机上调用钱包功能只能在 MetaMask 内置浏览器中使用。前往 MM 应用程序,并使用其内部浏览器。

© www.soinside.com 2019 - 2024. All rights reserved.