metamask显示“无效金额”。在使用EtherJS传输期间的MetAmask移动应用程序中,但在Web插件中工作正常

发布于 2025-01-26 16:09:43 字数 811 浏览 4 评论 0原文

使用MetAmask移动应用程序连接到DAPP时,我会遇到无效的量错误。它可以与浏览器插件一起使用,但在移动应用程序上不正常。我正在尝试使用Etherjs转移BUSD。我已经与BUSD合同和ABI联系了,就像我提到的那样,它在网络上正常工作,但在移动应用程序上显示“无效金额”。我真的很感谢您的帮助。

这是我的代码看起来像

             const price_r = ethers.utils.parseUnits(price_, 18);
              const {BUSDContract, signer} = await getContract();  
              const contract = BUSDContract.connect(signer)
              m_response = await contract.transfer(
                '0xf0e2fb4174A66dbD5A4B94B9D6331eA05460542d',
                `${amount}`,
                {
                  gasLimit: 3000000,
                }
              );

MetAmask浏览器插件时一样可行的。但是,当我切换到MetAmask移动应用程序时,它显示了无效金额,如下所示。

metAmask移动无效错误图像

I am getting an invalid amount error while connecting to my dapp using the metamask mobile appilication. It works fine with the browser plugin but not on the mobile app. I am trying to transfer BUSD using etherJs. I already connected with the BUSD contract and abi, and like I mentioned it works fine on web but shows "invalid amount" on mobile app. I'd really appreciate the help.

Here's what my code looks like

             const price_r = ethers.utils.parseUnits(price_, 18);
              const {BUSDContract, signer} = await getContract();  
              const contract = BUSDContract.connect(signer)
              m_response = await contract.transfer(
                '0xf0e2fb4174A66dbD5A4B94B9D6331eA05460542d',
                `${amount}`,
                {
                  gasLimit: 3000000,
                }
              );

This works quite when with the metamask browser plugin. However, when I switch to the metamask mobile app it shows the invalid amount as shown below.

Metamask mobile invalid error image

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不喜欢何必死缠烂打 2025-02-02 16:09:43

添加气候和加油站:

const gasLimit = await Contract.estimateGas.transfer(to, amount, {from: account });
const gasPrice = await library.getGasPrice();
    
const tx = await Contract.transfer(to, amount, {
  from: account,
  gasLimit: gasLimit,
  gasPrice: gasPrice
});
const response = await tx.wait();
return response;

Add gasLimit and gasPrice:

const gasLimit = await Contract.estimateGas.transfer(to, amount, {from: account });
const gasPrice = await library.getGasPrice();
    
const tx = await Contract.transfer(to, amount, {
  from: account,
  gasLimit: gasLimit,
  gasPrice: gasPrice
});
const response = await tx.wait();
return response;
旧时模样 2025-02-02 16:09:43

以防万一任何人介入这个问题,我就可以通过从Etherjs转换为Web3来解决它。

Just in case anyone comes into this issue, I was able to resolve it by switching from etherjs to web3.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文