Metamask is not being launched after clicked the Moralis launch button

Hello there, well like you can see in the subject, metamask isn’t running after I click the launch button, I have checked the guide step by step and I tried using testnet and mainnet but I got the same issue. Please help, thanks!

Hi @Billyb,

Could you mention which tutorial you were following?

Also, please post your code over here. And describe your issue in detail.

For more information on how to write a post, please check out this instruction list -

If you’re following the rarible code, check this out -

Thanks,

You also have to install MetaMask browser plugin in case that you didn’t do that already.

Hello guys, thanks for the answer.

  • I followed this guide: https://docs.moralis.io/guides/build-a-simple-dapp-in-3-minutes
  • Metamask is installed and I’m using Brave browser to launch it.
  • I’m trying to create my first dapp with the intention to create a nft game
  • This is the code I have created with VS: (I covered some ID and server details for this post)
<!-- Moralis SDK code -->

<script src="https://cdn.jsdelivr.net/npm/[email protected]/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

  Moralis.initialize("OLTABHTIk8m6Zp0PVkegzIz8cG862Ely********");

  Moralis.serverURL = "https://oxxm********.bigmoralis.com:2053/server";

  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>

Thanks for the help!

Is there any error on console when you load the page or when you click the button?

I’m also having the same issue with this other tutorial to build the first dapp: https://www.youtube.com/watch?v=jdx2H1alijQ&list=TLPQMTAwOTIwMjEDsjd1y1ohDQ&index=4

after clicking the Sign-in button Metamask does not open. I followed the tutorial step by step, copied the same and didn’t work, then I found that in Moralis documentation the code has been updated from Moralis.Web3. Authenticate to Moralis.Authenticate so i tried with the new code but did not work either. I don’t know how to go on from here.

This is the exact authentication code from the tutorial and does not work:

console.log('hello world');

// connect to Moralis server

Moralis.initialize("OVQv4GzkGYKOJmcd2UE0wF6AGh4Czz6Vlq6Sfzn8");

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

login = async () => {

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

        console.log('logged in');

    })

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

}

Then I tried with the updated code as it is showing in documentation right now, and did not work either:

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(function (user) {

        console.log(user.get('ethAddress'))

    

    })

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

}

Did you click on metamask plugin first (sometimes it asks for the page to be reloaded in order to be accessible for current page)?
In this last screen shot I don’t see a login button and a message/error when you press it.

I have reloaded the page endless times, Metamask has always been open, I shifted from all networks, testnet and the Ganache account but shows that Metamask is not connected but does not say how or where is that button to make it.
Also on the Console it never showed the “Hello world” nor the “logged in” string from the authenticate function either. The console is empty

There is no error message, when I press the sign in button nothing happens, and nothing showing on the console

Try a simple application (html) that only tries to authenticate with Moralis. At authentication it should open MetaMask. And post here all html code for that simple application if it doesn’t work. You could make sure it uses latest version of Moralis SDK, 0.0.44

This is the html of the sign in dapp:

<!doctype html>

<html lang="en">

  <head>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="description" content="">

    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">

    <meta name="generator" content="Hugo 0.88.1">

    <title>The LoginComponent</title>

    <link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/sign-in/">

    <link href="css/bootstrap.min.css" rel="stylesheet">

    <link rel="stylesheet" href="signin.css">

    <link rel="stylesheet" href="style.css">

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>

    <script src="https://unpkg.com/moralis/dist/moralis.js"></script>

           

  </head>

  <body class="text-center">

    

<main class="form-signin">

  <form>

    <img class="mb-4" src="moralislogo.png" alt="" width="72" height="57">

    <h1 class="h3 mb-3 fw-normal">Please sign in</h1>

    

    <div class="form-floating">

      <input type="text" class="form-control" id="user-username" placeholder="Username">

      <label for="user-username">Username</label>

    </div>

    <div class="form-floating">

      <input type="email" class="form-control" id="user-email" placeholder="[email protected]">

      <label for="floatingInput">Email address</label>

    </div>

    <button id= "btn-login" class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>

    <p class="mt-5 mb-3 text-muted">&copy; 2017–2021</p>

  </form>

</main>

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

    

  </body>

</html>

how do I make sure I’m using the latest version of Moralis SDK? where should I check exactly?

You should be fine related to latest Moralis version, are you sure main.js gets loaded?
Can you put some console log inside main.js to see that it is at least loaded? I see a possible html syntax error there near main.js

I can put some console.log on console but it is not showing the “hello world” console.log from the initial line of main.js.

that would be the sign that is loaded or how do I know main.js is loaded?

When is loaded you should see that “hello world”, but in order to see it you should refresh the page while console is opened.

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