web3modal
web3modal copied to clipboard
Cannot send transaction on mobile
My problem is that it works great on PC. On mobile (android), it connects fine using wallet connect. When I send a transaction, it opens up the option to connect with metamask and trustwallet, but on both I get no pop up to approve the transaction. I am on binance. Here's my code:
const providerOptions = {
walletconnect: {
package: WalletConnectProvider,
options: {
bridge: "https://bridge.walletconnect.org",
rpc: {
56: "https://bsc-dataseed.binance.org/",
},
network: "binance",
},
},
};
web3Modal = new Web3Modal({
cacheProvider: false, // optional
providerOptions, // required
disableInjectedProvider: false, // optional. For MetaMask / Brave / Opera.
});
provider = await web3Modal.connect();
web3 = new Web3(provider);
const data = contract.methods.buyTokens().encodeABI();
const gasPrice = await web3.eth.getGasPrice();
const tx = {
from: account,
to: contract.options.address,
gasPrice,
data,
value: web3.utils.toWei(amount, "ether"),
};
if (!web3) {
onConnect();
} else {
try {
const txHash = await web3.eth.sendTransaction(tx);
console.log(txHash);
} catch (error) {
console.log(error);
}
}
not work for me , Join my TG group to discuss
Is there any update?
With stable version 2.0.0 of Web3Modal now released, we are officially dropping support for version 1.x Due to this this issue/pr was marked for closing. It is highly recommended to upgrade as 2.x will be receiving further updates that will enable functionality for some of our newer sdks like auth and push as well as support for WalletConnect v2 (See this post about WalletConnect v1 being deprecated https://medium.com/walletconnect/walletconnect-v1-0-sunset-notice-and-migration-schedule-8af9d3720d2e)
If you need to continue using Web3Modal 1.x and require this feature/fix implemented, we suggest adding it via forking V1 branch.