Metamask is not being launched after clicked the Moralis launch button

Yes, I refreshed it many times and console is blank, not showing anything at all, just that line "@metamask/legacy-web3 - Injected web3. VM4423:1 "

Evidently is not being loaded. The video was uploaded yesterday, I followed everything step by step in slow motion. I also tried with the 2 version of the documentation code, the one in the video (from may) and the one that is showing right now at documentation. The ā€œmain.jsā€ html is exactly the one he is doing in the video up to minute 42.

how to make it load, that is the question.

I donā€™t know what else to do. Iā€™m learning, I donā€™t know how to fix code myself

Try to replace

</main>

><script> src="main.js" </script>

with

</main>

<script> src="main.js" </script>

Nope, simply isnā€™t openning the metamask or doing anything else, but no errors

okā€¦
try this then: <script src="main.js" ></script>

1 Like

it was that

<script src="main.js" ></script>

now it worked. Thanks

it worked by changing to <script src="main.js" ></script>

1 Like

Now it authenticate but the USER object is not being created and stored automatically in Moralis server, the User row in the table remains in 0, like all the rest.
What am I missing?

console.log('hello world');

// connect to Moralis server

Moralis.initialize("OVQv4GzkGYKOJmcd2UE0wF6AGh4Czz6Vlq6Sfzn8");

Moralis.serverURL = "https://krkxhau0hur3.usemoralis.com:2053/server";

login = async () => {

    await Moralis.authenticate().then(async function (user) {

        console.log('logged in')

        user.set("name", document.getElementById('user-name')).value;

        user.set("email", document.getElementById('user-email')).value;

    await user.save();

    })

}

document.querySelector('#btn-login').onclick = login;


You should see users added even after you only authenticate with MetaMask. Are you sure you are looking at the right Moralis server dashboard?

Yes, is the only Server I have set by now. Iā€™m following the tutorial step by step.
I set it to ā€œtestnetā€, so now Iā€™m using Rinkeby testnet, but I changed into Ganache but itā€™s still not showing anything in Moralis Dashboard

This is the error Iā€™m getting in the code with Moralis.Initialize()

Ignore it. If you correctly provided SDK import in html it will work correctly.

Iā€™ve just tried to signup on your server. Do you see my user object?

Yes, the new user object appeared

In the Signin.html I used <script src="main.js" ></script> to connect it with the main.js where the Moralis SDK connection is, I think

You can try it yourself:

Let me know how it will work for you

I tried it, I logged in there, it lets me authenticate with Metamask but no new user showing up in the Moralis Server, there still your User as the only user.
It seems everything is working as you could logged in but there is something my code or my connection with the Moralis server. I tried changing browser to Brave and Firefox but no change

Are you trying to log in with data inputed? How does it work if you specify email and name?

Yes Iā€™ve tried both just clicking on the button directly and by inputting the username and email, in both cases triggers Metamask, it lets me sign and thatā€™s it.
No change in the server

Marcel could you please share over here the code you used to fix the Metamask issue? I havenā€™t checked my error so I havenā€™t fixed yet. Thanks in advance!

Iā€™m trying to build a nft videogame for a friend and connect his marketplace with metamask, any advice or recommended docs to check?

Btw, thanks for developing this tool, this saves us tons of hours and headaches to non-coders.

Hi Billyb,

Iā€™ve just started with Moralis and I had the same issue as you - button was unresponsive and didnā€™t open Metamask. To solve I kept my original code (I wrote it all out as I find it better for learning personally) and then copy and pasted the code in the tutorial into a new .html file and ran that - it ran perfectly. I ran through each line (in VS Code you can split the screen to show 2 code docs at the same time) to make sure everything matchedā€¦ my issue was in

                let user = Moralis.User.current();
                if(!user) {
                    user = await Moralis.authenticate();
                }
                console.log("Logged in user:", user);

I didnā€™t capitalise the ā€œUā€ in Moralis.User.current - changing that worked for me. If you apply a similar approach for your code you may find the issue. If youā€™re still having an issue let me know and Iā€™ll test your code tomorrow - unfortunately I need to run out right now, just thought Iā€™d jump in and try and help you quickly.

Hope this helps you resolve the issue though. :slight_smile:

1 Like

So how is your final Login object version? like this?

login = async () => {

    let user = Moralis.User.current();

    if(!user) {

    user = await Moralis.authenticate();

    }

    console.log("Logged in user:", user);

    user.set("name", document.getElementById('user-name')).value;

    user.set("email", document.getElementById('user-email')).value;

    await user.save();

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

    }

My code worked in the console when using both

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

and

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

and finally the server dashboard added the new user, but only by using the console, it hasnā€™t worked by clicking the button, and also hasnā€™t worked to jump from signin.html to the dashboard.html after authenticating with Metamask. It only works using the console manually

I tried your code like that but is not working either