[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();
    if (!user) {
      try {
        const user = await Moralis.authenticate({ provider: "walletconnect" });
        Moralis.authenticate({ signingMessage: 'TESZT', provider: 'walletconnect', chainId: 56}).then(function (user) {
        }).catch((err) => {
      } catch(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?

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:
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:

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