Moralis authenticate ios/ android / trustwallet and more


i might just have not found the right tutorial… but i am currently facing a problem with WalletConnect and iOS/android Trustwallet and others. On PC everything is working… even with walletconnect and ios-trustwallet… but as soon as people connect on mobilephone with walletconnect and trustwallet or other providers, the wallet-connection is working… but everything else not. So for example if they try to “buy a ticket” for the lottery… no message appears on Trustwallet for approving/buying … as it works on pc i can be sure the “base programming” is working.

This is the code i use for let the people buy a ticket:

   const currentUser = Moralis.User.current();
	if (currentUser) {
		window.web3 = await Moralis.Web3.enable();
		const userAddress = currentUser.get("ethAddress");
        const contrAddress = "0xf8....";
        var tickets = parseInt($( "#ticketamount option:selected" ).text())*1000;
        let contractinstance = new web3.eth.Contract(abxi, "0xa7.....");
        let x = await contractinstance.methods.approve(contrAddress, Moralis.Units.Token(tickets, "18")).send({from:userAddress});

        let contract = new web3.eth.Contract(abiy, "0xf8f2......");
        let enterlottery = await$( "#ticketamount option:selected" ).text())).send({from:userAddress});
     alert("Please connect your wallet first");

am i anything missing to interact on mobile?

thx and sorry for annoying again haha

1 Like

Hey @Hydracoder

Moralis.Web3.enable() is from outdated syntax. On new versions you should use Moralis.enable().

If you want to use non-injected providers you need to specify provider:

Also take a look at Wallet connect takes me to trust wallet page

lol damn my fault… i just saw the “enable” part and was thinking i am already using new syntax… seems i have to learn to read again. Thanks for your help! will try it out and if still any problems i will let you know.

is there a way to check if a user is connected with metamask or walletconnect? as i have 2 buttons on my website where people can either use metamask or walletconnect… i use with


either with or without provider added.

Hey @Hydracoder

Sorry for the late response :raised_hands:

const provider = window.localStorage.walletconnect ? "walletconnect": "Metamask";

awesome that seemed to work. Thank you very much for the help!

1 Like