WalletConnect auth is not functioning

Been trying to get this sorted for a couple days now. I’m not sure what has happened but the Moralis.authenticate({ provider: “walletconnect”, chainId: 56 }); code is absolutely haulting my code. For example, I click the “Sign in with WalletConnect” button, the QR code appears on the screen, I proceed with the WalletConnect option from mobile device. The QR code disappears, and the phone looks like it is connected. However, the code does not continue in the DApp. I am unable to send any kind of transaction or signature request from the DApp. The exact same functions, work properly using MetaMask from desktop. I have also tried stripping away all m extra code, as well as trying to do the same thing from the Demo WalletConnect apps from the Moralis Github and I’m getting the same result. The only thing I get in console is the bridge connect info and then the code just stops. No errors that I can see. It’s like Moralis is not acknowledging the WalletConnect login. I have tried all recent versions of the WalletConnect script with the same results. I will put my login functions for both MetaMask and WalletConnect below:

MM Login:

async function login() {
    try {
        currentUser = Moralis.User.current();
        if (!currentUser) {
            document.getElementById("login_button").innerText = "Authenticating...";
            currentUser = await Moralis.authenticate();
            document.getElementById("vote_token_1_button").disabled = false;
            document.getElementById("vote_token_2_button").disabled = false;
            document.getElementById("vote_token_3_button").disabled = false;
            document.getElementById("vote_token_4_button").disabled = false;
            document.getElementById("vote_token_5_button").disabled = false;
            setHelperData();
        } else {
            logOut();
        }
        document.getElementById("login_button").innerText = "Logout";
        logged_in = true;
    } catch (error) {
        if (error.message == "MetaMask Message Signature: User denied message signature.") {
            alert("Login cancelled")
            document.getElementById("login_button").innerText = "Sign in with Metamask";
        }
    }
}

WC Login:

async function loginWC() {
    try {
        currentUser = Moralis.User.current();
        if (!currentUser) {
            document.getElementById("login_button_wc").innerText = "Authenticating...";
            currentUser = await Moralis.authenticate({ provider: "walletconnect", chainId: 56 });
            document.getElementById("vote_token_1_button").disabled = false;
            document.getElementById("vote_token_2_button").disabled = false;
            document.getElementById("vote_token_3_button").disabled = false;
            document.getElementById("vote_token_4_button").disabled = false;
            document.getElementById("vote_token_5_button").disabled = false;
            setHelperData();
        } else {
            logOut();
        }
        document.getElementById("login_button_wc").innerText = "Logout";
        logged_in = true;
    } catch (error) {
        if (error.message == "User closed modal") {
            alert("Login cancelled")
            document.getElementById("login_button_wc").innerText = "Sign in with WalletConnect";
        }
    }
}

I think that you also need to use enableWeb3 to use that web3 instance to send transactions

on mobile you also have the option to select a wallet and open it, not only to scan a QR code, I think that you can scan that QR code also on desktop

you may also need a https connection for your site to make walletconnect work

enableWeb3 gets called with the Init function when the site loads.

But yes, I need the QR code that I scan from desktop to function. The problem is, the code never gets past the Moralis.authenticate({ provider: “walletconnect”, chainId: 56 });

The live distribution that utilizes this is on an HTTPS connection.

do you see any error in your browser console?

if you add a console.log(“here”) after await Moralis.authenticate that message is not going to be displayed?

So now it’s working, with literal 0 change to code and 2 days of trying and hours of lost time…

No idea what’s going on. But the issue is resolved.

Hopefully it stays that way haha.

Thanks for the reply