I use Metamask App in Android phone.
When login by Wallet Connect, it’s successfully.
But when I call a smart contract function that need to pay gas fee, it says:
Uncaught (in promise) Error: Non ethereum enabled browser
at moralis.js:4497
at tryCatch (moralis.js:25797)
at Generator.invoke [as _invoke] (moralis.js:26027)
at Generator.next (moralis.js:25852)
at asyncGeneratorStep (moralis.js:25244)
at _next (moralis.js:25266)
at moralis.js:25273
at new Promise ()
at new Wrapper (moralis.js:28332)
at moralis.js:25262
How can I fix it?
As I said earlier in the discord, It seems like you are trying to use web3
from window.ethereum
instead of WC provider. But we need to see your code
if (provider == 'walletconnect') {
const user = await Moralis.authenticate({ provider: provider});
} else {
const user = await Moralis.authenticate();
}
}
const web3 = await Moralis.enable();
const contract = new web3.eth.Contract(marketplaceABI, marketplaceAddress);
const result = await contract.methods['buyNFTs'](quantity).send({from: address, value: quantity * price });
let web3;
if (provider == 'walletconnect') {
const user = await Moralis.authenticate({ provider: provider});
web3 = await Moralis.enable({ provider });
} else {
const user = await Moralis.authenticate();
web3 = await Moralis.enable();
}
1 Like
Thanks. I will check.
If users reload the page, how can we keep the variable of “web3” to be available after reloading (they won’t login again)?
I’ve sent you this topic in the discord before, take a look at Send transactions web3 provider WalletConnect again
1 Like
OK it’s working. thanks
1 Like
Happy BUIDLing
1 Like