Unable to connect trustwallet when using wallet connect with web3modal

2.5k Views Asked by At

I am using web3modal for wallet connection. I have tried implementing wallet connect as a provider option, it is working with metamask android app and wirex wallet, but somehow trust wallet is not working. When I scan QR code using trust wallet android app it says connecting it may take a few seconds and then nothing happens.

Here is my implementation:

import WalletConnectProvider from '@walletconnect/web3-provider';
import Web3Modal from 'web3modal';

const options = new WalletConnectProvider({
  rpc: {
    137: 'https://matic-mainnet.chainstacklabs.com',
  },
  infuraId: INFURA_ID,
});

const providerOptions = {
  walletconnect: {
    package: WalletConnectProvider, // required
    options: options,
  },
};
const web3Modal = new Web3Modal({
    network: 'mainnet',
    cacheProvider: true,
    providerOptions, 
  });
}

const provider = await web3Modal.connect();
2

There are 2 best solutions below

1
On

You can try use open-source Angular library facilitates the connection between users and web3 applications, making it easier for them to engage in transactions seamlessly. This library enhances the user experience and simplifies the process of interacting with web3 applications.

https://web3-connect.b-ee.io/

0
On

In my case the reason trustwallet wasn't working was becuase my dapp didn't have a meta title. As soon as I added:

<Head>
  <title>My decentralized app</title>
</Head>

I was able to connect trust wallet.