[SOLVED] Metamask does not open

I am creating a Dapp and i have put this code in visual:

<!-- Moralis SDK code -->

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

<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
<h1>Gas Stats With Moralis</h1>

<button id="btn-login">Moralis Login</button>

<button id="btn-logout">Logout</button>

<script>

  // connect to Moralis server

  const serverUrl = "https://giailjch79uo.usemoralis.com:2053/server";

  const appId = "c2ztbZHPZN1gFpG1Xyt8wFxGRmCv3Flwtaqsbicn";

  Moralis.start({ serverUrl, appId });

    // add from here down

async function login() {

let user = Moralis.User.current();

if (!user) {

  user = await Moralis.authenticate();

}

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

}

async function logOut() {

await Moralis.User.logOut();

console.log("logged out");

}

document.getElementById(“btn-login”).onclick = login;

document.getElementById(“btn-logout”).onclick = logOut;

</script>

But when i open the file in the server and I click in Moralis login Metamask does not appear

hello

you can read here about how to post code on forum

you can read here about how to use version 1 of the sdk:

you can also look in the browser console for errors

I am sure that I have copied the code fine. I do not see where i have fail

on what code you are referring? where from did you copy it?

I don’t see moralis-v1 in your code

My referring is this:

-https://moralis.zendesk.com/hc/en-us/articles/4745944906130-How-to-create-a-Moralis-dApp
-https://moralis.zendesk.com/hc/en-us/articles/4745380094098
-https://moralis.zendesk.com/hc/en-us/articles/4777219042962

I have done it like this, but Metamask does not open

I have done my friend, i had to put moralis-v1.

Thanks so much, If i have more questions i will write you :smiley:

1 Like