'Metamask is showing "invalid amount" in metamask mobile app during transfer with etherjs but works fine in web plugin
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.
Solution 1:[1]
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;
Solution 2:[2]
Just in case anyone comes into this issue, I was able to resolve it by switching from etherjs to web3.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mad |
Solution 2 | flair |