[SOLVED] Moralis and WalletConnect issue with Trust wallet

Hi there,

I am trying to make the Vanilla JS example work with trust wallet using wallet connect.
Basically I have the vanilla code, at the moment it looks like this:


  async function login() {
    let user = Moralis.User.current();
    console.log(user);
    if (!user) {
      try {
        const user = await Moralis.authenticate({ provider: "walletconnect" });
        console.log(user);
        /*
        Moralis.authenticate({ signingMessage: 'TESZT', provider: 'walletconnect', chainId: 56}).then(function (user) {
          console.log(user);
        }).catch((err) => {
          console.log(err);
        });
        */
      } catch(error) {
        console.log(error)
      }
    }
  }

When running this on localhost I experience the following:
I click the login button. In the console I see the wallet connect hash (wc:839ddb9d-1a81-42e1-aa13-2224ā€¦) and the QR code pops up.
I read the QR with trust wallet and I get an alert, that ā€œVanilla boilerplate wants to connect to your walletā€. I click connect. After that two things happen: The QR code disappears (meaning the the desktop app knows that I clicked on the button), and trust wallet pops up the signature request confirmation. I click confirm, but after that I see no new information in my console on the desktop. Also I donā€™t see this wallet as a User in my Moralis server dashboard.

However if I do all of this with Metamask on my phone (so still wallet connect, but with metamask), then everything is the same, except that after signing the message the console on the desktop browser gives me the User details and the User object pops up in my Moralis admin dashboard.
So my buest guess is that somethingā€™s wrong parsing the signed message by Trust Wallet, but since I get no errors whatsoever, I donā€™t know where to go next.

Any ideas on that?
Thanks,
Zoltan

not sure if this helps: Wallet connect takes me to trust wallet page

you could also test from https://codesandbox.io/, sometimes not everything works from localhost

Unfortunately it seems to be a different issue. However I did notice that they provided another example:
https://forum-tests.vercel.app/
Iā€™m not sure what it is, but it also doesnā€™t work for me.

Also I tried to upload it to a remote server with a valid SSL certificate but it didnā€™t make a difference.

Hereā€™s some additional information that I just discovered:
First I replaced Moralis.authenticate with Moralis.enableWeb3.
Using this I was able to confirm that connecting with the wallet in face works, I dumped the output to the console.
The next thing that I discovered is that the output of enableWeb3 contains this: version: ā€œ1.6.1ā€
However I included walletconnect 1.6.6 in my code. Thatā€™s something strange, is it possible that Moralis uses a bundled version of Wallet Connect?

Anyway, Iā€™ll try signing messages separately and see what happens.

Moralis SDK shouldnā€™t include wallet connect, what version of Moralis SDK are you using?
you can get the version with this command: Moralis.CoreManager.get("VERSION")

It says the version is:
js0.0.132

ok, it means that you have latest version, it should not include wallet connect

Strangely enough it looks like a reinstall of Trust Wallet on my phone solved my issue.

1 Like