1

I’m following the YouTube tutorial for authenticating users with metamask but getting an error.

Code:

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

    
</head>

<body>
    
    
    <button onclick="login()">Login with Metamask</button>

    <script>
        
        Moralis.initialize("hbLGi00XmJZOwrkmjGeYXLmPOxdgg4Bj2GyAA6Gx"); // Application id from moralis.io
        Moralis.serverURL = "https://fc7em77djryo.moralis.io:2053/server"; //Server url from moralis.io
    
        async function login(){
            console.log("login clicked");
            var user = await Moralis.Web3.authenticate();
            }
        
    
    </script>
  </body>
</html>

Error:

moralis.js:4497 Uncaught (in promise) Error: Non ethereum enabled browser
    at moralis.js:4497
    at tryCatch (moralis.js:24495)
    at Generator.invoke [as _invoke] (moralis.js:24725)
    at Generator.next (moralis.js:24550)
    at asyncGeneratorStep (moralis.js:23942)
    at _next (moralis.js:23964)
    at moralis.js:23971
    at new Promise (<anonymous>)
    at new Wrapper (moralis.js:26960)
    at moralis.js:23960

Tutorial Video: https://youtu.be/6BfOtYfwFBI

1 Answer 1

2

For Moralis to work properly, you have to host your pages through a server. When you open the HTML file directly, you will face this issue.

This has been mentioned in the moralis docs for your reference over here - Uncaught Reference error- Non Ethereum Browser

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.