Metamask Confirm button not working, couldn't confirm transaction for a smart contract.
I use JS and WalletConnectProvider (website project). Connecting to Metamask by WalletConnect, then call transfer function for custom token contract. I use the same code on desktop and it works and transferring token. Exactly the same code doesn't work on mobile (for Metamask Mobile app). Checked IOS and also Android - the same issue. Please tell me what is wrong with my code:
<script src="https://cdn.jsdelivr.net/npm/@walletconnect/web3-provider@1.8.0/dist/umd/index.min.js"></script>
<script src="https://[mywebsitescriptspath]/web3.min.js"></script> // 1.8.0
<script type="text/javascript">
var contract
var accountFrom
const ABI = "... abi here....."
var provider = new WalletConnectProvider.default({
infuraId: 'my infura id',
rpc: {
1: "https://mainnet.infura.io/v3/[myinfuraid]",
56: "https://bsc-dataseed.binance.org/"
},
})
const contractAddress = '0xcontraddresshere'
const receiver = '0xreceiveraddresshere'
var connect = async () => {
await provider.enable()
var web3 = new Web3(provider)
web3.givenProvider = web3.currentProvider
web3.eth.givenProvider = web3.currentProvider
web3.eth.accounts.givenProvider = web3.currentProvider
window.w3 = web3
contract = new w3.eth.Contract(ABI, contractAddress)
await w3.eth.getAccounts().then(accounts => {
accountFrom = accounts[0]
})
}
connect()
// function called after the button click
var sendtransaction = async () => {
let vall = 100
let calcAmount = w3.utils.toWei(vall.toString())
let transfer = await contract.methods.transfer(receiver, calcAmount);
await transfer.send({from: accountFrom})
.on('transactionHash', function(hash){
console.log(hash)
})
}
</script>
I tried many different things but it doesn't work.
Tested on wifi, on 4g, on different mobile browsers, on different smartphones (android and IOS). no success.
The problem started from 5.9.0 Metamask app version.
UPDATE: Now at 5.10.0 version it doesn't recognize custom contract token. For example when I want to transfer 1 token, it shows 1 BNB. Last version was better :))
There are open issues on github:
- https://github.com/MetaMask/metamask-mobile/issues/5193
- https://github.com/MetaMask/metamask-mobile/issues/5235
- https://github.com/MetaMask/metamask-mobile/issues/5260
No solution till now - after 14 days.