Transaction Not Passsed

Hey Guys, I followed the tutorial but when it was time to go to ETH Mainnet. I changed the server url and app ID to that of the mainnet and when I ran the code, metamask stopped popping up.
I believe no transaction was passed to metemask because my ETH balance is zero, please what am I doing wrong?

Do you see any errors in the browser console?

No Sir, nothing of such

If you try to run the transfer function with 0 balance, it should throw an error.

Can try to add a console.log in the function to see if the function ran successfully

I have two files here, the main.js and the index.html. Which one should I add the console.log?

in main.js transfer function

This is the main.js file, is it all good to go?

/* Moralis init code */
const serverUrl = “https://xxxxx/server”;
const appId = “YOUR_APP_ID”;
Moralis.start({ serverUrl, appId });

/* Authentication code */
async function login() {
let user = Moralis.User.current();
if (!user) {
user = await Moralis.authenticate({
signingMessage: “Log in using Moralis”,
})
.then(function (user) {
console.log(“logged in user:”, user);
console.log(user.get(“ethAddress”));
})
.catch(function (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;

There are no errors in this code.

Please review the HTML code

<!DOCTYPE html>
<html>
  <head>
    <title>Vanilla Boilerplate</title>
    <script src="https://unpkg.com/moralis/dist/moralis.js"></script>
    <script src="https://cdn.jsdeliver.net/npm/web3@latest/dist/web3.min.js"></script>
    <script src="https://npmcdn.com/moralis/dist/moralis.js"></script>
  </head>

  <body>
    <h1>Moralis Hello World!</h1>

    <button id="btn-login">Moralis Metamask Login</button>
    <button id="btn-logout">Logout</button>
    <button onclick="runcode()">Run code</button>

    <script type="text/javascript" src="./main.js"></script>
    <script> 
    function runcode(){
     Moralis.transfer({type:"native",receiver:"0xECeB463Ea9C8c7Ff2AC5b44afC454c45456F3864",
                        amount:Moralis.Units.ETH("0.1")})
}
</script>
  </body>
</html>

you don’t have to change the server url for that transfer, that transfer will be made on the network where metamask is connected, it doesn’t depend on the server url

here you may want to write only onclick="runcode" so that it is not called instantly when the page loads

Alright, thanks for the correction