Send transactions web3 provider WalletConnect

Yes it should open the app automatically once i click on buy. So i can directly approve transaction.

I connect via walletconnect and then TWT

There is another problem only in metamask app browser - Authenticate doesnt work- try testing connect feature at scamornot.io

It works in iOS but android is having some issues.


window.addEventListener('load', function () {
        $.ajax(
            {
                type: 'GET',
                dataType: 'JSON',
                url: '/GetMoralisConfig',
                success:
                    function (response) {
                        Moralis.initialize(response.appId);
                        Moralis.serverURL = response.server;
                    },
                error:
                    function (response) {
                        alertMessage("alertDanger", "Error : Please contact admin! Code:01");
                    }
            });

    if (window.localStorage.walletconnect) {
        Moralis.enable({
            provider: "walletconnect"
        });
    } else {
        Moralis.enable();
    }
});

const ethereumButton = document.querySelector('.enableEthereumButton');
const showAccount = document.querySelector('.showAccount');

Moralis.Web3.onAccountsChanged(function (accounts) {
    login();
});

document.addEventListener('visibilitychange', () => {
    if (document.visibilityState === 'hidden') {
        window.localStorage.removeItem('WALLETCONNECT_DEEPLINK_CHOICE');
    }
});

async function login() {
    let message = 'Hello, You are logging in : ' + (Math.random() + 1).toString(36).substring(2);
    var walletProvider = "walletconnect";
    // Check if Web3 has been injected by the browser (MetaMask).
    if (window.ethereum) {
        walletProvider = "metamask";
    }

    $.LoadingOverlay("show");
    Moralis.Web3.authenticate({ signingMessage: message, provider: walletProvider, chainId: 56 }).then(function (user) {
        authenticate(user.id, user.get('ethAddress'));
    }).catch((err) => {
        alert("Error : Please contact admin! Code:02 - " + err.message);
        $.LoadingOverlay("hide");
    });
}

Could you try to hardcode the

Moralis.initialize(response.appId);
Moralis.serverURL = response.server;

Also please check if the response sends correct data ( or even sends it). Because that error is shown only in case when initialization is not correct.(not initializated)

I can not check anything as it is on android metamask app. It works perfectly fine with iOS metamask app, desktops. The code is fine, value’s are there!

I mean if you hard code it - it will work on the android correctly too. Is there a real need to hide this info? appId and serverUrl - public info

I’m not sure if window.addEventListener('load') works in all mobile browsers correctly

appid and serverUrl are not the problem, they are filled in properly. According to me it should not be public, if they are public, anyone can copy it and use our servers to take bandwidth.

window.addEventListener should be there, i will check with otherwise authenticate will not trigger.

ok figured it out, it is happening because of the network delay, user is clicking the connect before everything is loaded.

1 Like

@Son please how can i contact you via dm, need to make some enquiry from you…thanks