Moralis walletconnect not working, Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'default')

Hi, Iā€™m a new with Moralis and still learning as I make progress. Iā€™m trying to create user signin by using wallets. Strange part is if I use MetaMask it works 100% perfect but when I use { provider: ā€˜walletconnectā€™ } it says: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ā€˜defaultā€™).
Hereā€™s my code:

<script>

        //moralis server connection

        const serverUrl = "******************";

        const appId = "******************";

        Moralis.start({ serverUrl, appId });

        async function meta(){

           user = await Moralis.Web3.authenticate();

           window.location.href = "accounts.html";

        }

        async function connect(){

           user = await Moralis.Web3.authenticate({provider: 'walletconnect'});

          // window.location.href = "accounts.html";

        }

     

        async function checkMeta(){

          const ethereum = window.ethereum;

           if(!ethereum || !ethereum.on){

             alert('This Application requires MetaMask Wallet, Please install MetaMask Wallet extension');

           }

        }

      </script>

And to connect with Moralis Iā€™m using:

<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
 <script src="https://unpkg.com/moralis/dist/moralis.js"></script>

Iā€™m using VS code and I do have walletconnect, web3-provider installed, hereā€™s my .json:

ā€œdependenciesā€: {

"@walletconnect/web3-provider": "^1.7.0",

"@web3-react/injected-connector": "^6.0.7",

"walletconnect": "^1.7.0",

"web3connect": "^1.0.0-beta.33",

"web3modal": "^1.9.4"

},

Iā€™ve been stuck on this for last two days, I decided to leave it because MetaMask works so just continue with that but decided to work on it as itā€™s not professional. Any help would be of great appreciation. Thank you.Preformatted text

1 Like

this is a demo app: https://github.com/MoralisWeb3/demo-apps/tree/main/moralis-vanilla-walletconnect

for wallet connect to work you will also need to have the site over https and maybe available over the internet

I donā€™t understand the connection between first js file that seems vanilla js and the second part with dependencies that seems to be react

I am using vanilla js but as I researched and tried out solutions I did install web3/walletconnect.

So youā€™re saying that the site has to in production for walletconnect to work?

Not necessarily in production, you can use a service la codesandbox or to upload/deploy the site on your Moralis static hosting

Itā€™s still doesnā€™t work.
I tried codesandbox and still MetaMask button allows connection but walletconnect button has no response, I tried it both ways, I used my code nothing happened I tried it with the demo code still no response.

I tried demo code in VS code again for testing and in developer console now it says:

Uncaught (in promise) TypeError: console is not a function

And I also deployed it using moralis-admin-cli deploy using terminal, if I follow the complete link I only get a blank page with a line i.e:

Cannot GET /deploy

and if I use only the http link: https://kbs5e7mhd009.usemoralis.com its just a lime green page with Moralis logo, says: coming soon, and in footer it just says: Powered by Moralis.

Iā€™m confused!.

this should work, you need a file with the name index.html in current folder and it will try to deploy by default what it is on current folder

that green page with Moralis logo is the default page when you donā€™t deploy anything

This page here is index.html and its in VS code source directory.

I usually run that directly from cmd in windows, this is the first message after executing moralis-admin-cli deploy:

moralis-admin-cli deploy
Specify Moralis Api Key:                           

Used cmd, still displays Moralis default page

do you have more than 1 server? maybe you deployed it to another server, it happened to me to write 2 for second server but actually it was deploying on the third server because the numbers for servers start from 0

I do have more server but I havenā€™t used it and itā€™s on sleep right now.

How far did it work with the deploy?
Did you get to see the servers list? Did you choose a number/server index after that?

I did Iā€™ll start another server to see if that solves this.

It didnā€™t work, first I was using a mainnet server now I tried it with a testnet, both didnā€™t work.

can you share your html code?
you should use Moralis.authenticate

I tried it both ways with Moralis.authenticate and Moralis.Web3.authenticate on both codesandbox and moralis-admin-cli deploy same result: No Successful Outcome

Iā€™m just gonna leave it for now and continue with only MetaMask and get someone to figure this out when I get some money to get someone.

Thanks for your help and time. I appreciate it.