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/[email protected]/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.