Hey, thanks for the response. Sorry it took me so long to get back to this project. I’ve been pretty busy. Update: The boilerplate has been updated since I made this post. Using the new boilerplate has helped bring some clarity to the issue due to it providing different error messages. Now it’s telling me that my browser is not Ethereum enabled, but I have the Metamask extension installed and even tried to log into it first just to get the same error message.
Here is the boilerplate I’m using for index:
<!DOCTYPE html>
<html>
<head>
<title>Vanilla Boilerplate</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 id="btn-login">Moralis Metamask Login</button>
<button id="btn-logout">Logout</button>
<script type="text/javascript" src="./main.js"></script>
</body>
</html>
And main:
const serverUrl = ""; //This field is not really empty. I just removed the value.
const appId = ""; //Same story here.
Moralis.start({ serverUrl, appId });
/** Add from here down */
async function login() {
let user = Moralis.User.current();
if (!user) {
try {
user = await Moralis.authenticate({ signingMessage: "Hello World!" })
console.log(user)
console.log(user.get('ethAddress'))
} catch(error) {
console.log(error)
}
}
}
async function logOut() {
await Moralis.User.logOut();
console.log("logged out");
}
document.getElementById("btn-login").onclick = login;
document.getElementById("btn-logout").onclick = logOut;
And here are the details of the error message I get in my browser now:
Error: Non ethereum enabled browser
at moralis.js:4629
at tryCatch (moralis.js:28071)
at Generator.invoke [as _invoke] (moralis.js:28301)
at Generator.next (moralis.js:28126)
at asyncGeneratorStep (moralis.js:27580)
at _next (moralis.js:27602)
at moralis.js:27609
at new Promise (<anonymous>)
at new Wrapper (moralis.js:32483)
at moralis.js:27598
This pops up at line 55 (console.log(error)) after clicking the login button.