[SOLVED].ExecuteFunction WalletConnect Mobile Issue

Hey guys i’m facing an issue on my mint Dapp

PROCESS

  • Open the Dapp
  • Open Metamask from mobile / trust wallet
  • Connect wallet choosing WalletConnect option
  • The Mobile app will ask you to Sign
  • The wallet connects perfectly to the Dapp
  • Now try to click on Mint Now

What should do: Open up a request to sign on mobile with the transaction value of the mintAmount x price
What it does: Open up a request to sign on Metamask Desktop with the transaction value of the mintAmount x price

CODE:

This is the write Function that the Mint Now button execute on click

Why it does this is because you got Moralis.enableWeb3() which by default will always revert to metamask if no provider option is passed, try pass in provider of walletconnect: Moralis.enableWeb3({ provider: "walletconnect" }).

Although, you don’t need web3Provider so far you already enabled web3.

Yeah you are right, passing in the provider it works… but on my Dapp the user has 2 option to login MetaMask or walletconnect, so I can’t enableweb3 with both.

How can Moralis solve this?

Thank you

You can keep the user provider choice somewhere ( e.g localstorage ) and use it later to handle that.

There’s no way to output what provider a user used to login?

You can catch that from what the user decides to authenticate with and store it.