[SOLVED] Dapp not connecting thru Walletconnect via Moralis enable function

Hey there, I am using moralis (1.11.0) with wallet connect (1.7.8). I have my app deployed to play store using moralis paid server. The issue coming in the app is this:
This is the code

  async testContract() {
    await Moralis.enableWeb3({
      chainId:5,
      mobileLinks: ['metamask'],
      provider: 'walletconnect',
    })
      .then(async () => {
        await Moralis.authenticate({
          chainId:5,
          provider: 'walletconnect',
          mobileLinks: ['metamask'],
          signingMessage: 'Mint via Digital Dope',
        });
      })
      .then(async () => {
        try {
          const options = {
            chain: '0x5',
            contractAddress: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
            functionName: 'mintToken',
            abi: this.contractABI,
            params: {
              tokenURI:
                'http://gateway.moralisipfs.com/ipfs/ID',
            },
            onSuccess: (tx: any) => console.log(tx),
            onError: (error: any) => console.log(error),
          };
          await Moralis.executeFunction(options).then((res) => {
            console.log('MINTED DATA', res);
          });
        } catch (error) {
          console.log('this error is from LIST NFT', error);
        }
      });
  }

The error is that the app is not connecting to metamask app (v7.3.1) via enable function

WebSocket connection to β€˜wss://s.bridge.walletconnect.org/?env=browser&host=localhost&protocol=wc&version=1’ failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED

Kindly help as this issue is disturbing my application

Hi @shirazshakeel86

It seems related to walletconnect. Since walletconnect has depriciated its v1 sdk you have to migrate to walletconnect v2 sdk.

Please check an example on the below github docs on how to migrate to the latest wallet connect.

And also repalce your moralis sdk version with the latest moralis-v1 sdk.
"moralis-v1": "^1.13.0"

But after upgrading my project, would there be some functions that moralis won’t support?

I believe it should not affect any older functions as there were not many updates. However please test your app after making the changes :raised_hands:

Will do. Thankyou for your assistance, Will get back to you if I face any issue.

1 Like

You mentioned moralis-v1, is there a difference in moralis and moralis v-1?

It is actually the same we only added a new fix in moralis-v1 sdk.
btw after installing moralis-v1 you also have to update your imports accordingly.

1 Like

How I can limit the user to use metamask wallet only as previous wallet connect and moralis had mobilelinks options, but now there is no option to specify it. The wallet connect shows a lot of wallets. I only need metamask. How can I do this ?

As per the github docs, there is a new option for it.

Since we are directly using the walletconnect package, maybe check if they have a recommend way.

1 Like

I tried this but its still showing all of the installed wallets i.e. trustwallet and metamask.

  await Moralis.enableWeb3({
      chainId: 5,
      qrModalOptions: ['metamask'],
      projectId: this.projectID,
      provider: 'walletconnect',
    })

Hi, Please replace this line with the below code.

    qrModalOptions: {
      themeMode: "dark",
      explorerRecommendedWalletIds: [
        "c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",
      ],
    },

The value of the wallet Id which you can pass to the explorerRecommendedWalletIds array can be found in the below page.

I found out about the explorerRecommendedWalletIds option in wallet connect docs.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.