WalletConnect / walletconnect-monorepo

WalletConnect Monorepo
Apache License 2.0
1.47k stars 715 forks source link

connect to trust wallet and get user addresses (btc,eth,bsc etc) #550

Closed optima66 closed 1 year ago

optima66 commented 3 years ago

I use this code to connect to trustwallet: https://docs.walletconnect.org/quick-start/dapps/client

This is my code:


          const Web3Modal = window.Web3Modal.default;
          const WalletConnectProvider = window.WalletConnectProvider.default;
          const Fortmatic = window.Fortmatic;
          const evmChains = window.evmChains;

          const WalletConnect = window.WalletConnect
          cosnt QRCodeModal = window.QRCodeModal

          const connector = new WalletConnect({
            bridge: "https://bridge.walletconnect.org", // Required
            qrcodeModal: QRCodeModal,
          });

          // Check if connection is already established
          if (!connector.connected) {
            // create new session
            connector.createSession();
          }

          // Subscribe to connection events
          connector.on("connect", (error, payload) => {
            if (error) {
              throw error;
            }

            // Get provided accounts and chainId
            const { accounts, chainId } = payload.params[0];
          });

But now I don't understand - I should see a popup window with qrcode how do I summon this window?

finessevanes commented 1 year ago

Docs: https://docs.walletconnect.com/1.0/quick-start/dapps/node#initiate-connection

// Check if connection is already established
if (!connector.connected) {
  // create new session
  connector.createSession().then(() => {
    // get uri for QR Code modal
    const uri = connector.uri;
    // display QR Code modal
    WalletConnectQRCodeModal.open(
      uri,
      () => {
        console.log("QR Code Modal closed");
      },
      true // isNode = true
    );
  });
}