Problems interacting with smart contract

Can someone let me know where i am going wrong here ?

// main.js

const serverUrl = "https://tfnpgrbijuyl.usemoralis.com:2053/server";
const appId = "GZkY9b1x6psaRSiuAyoPI7aC13HZxwIZGRpSvig0";
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!" })
      await Morlais.enableWeb3();
      console.log(user);
      console.log(user.get('ethAddress'));
   } catch(error) {
     console.log(error)
   }
  }
}

async function logOut() {
  await Moralis.User.logOut();
  console.log("logged out");
}

async function approve() {
    let options = {
        contractAddress: "0x31E5066dBf561b5d57B6711029fCfF1a158cf086",
        functionName: "handleApproval",
        abi: [{
            "inputs": [
                {
                    "internalType": "contract IERC20",
                    "name": "_token",
                    "type": "address"
                },
                {
                    "internalType": "uint256",
                    "name": "_numTokens",
                    "type": "uint256"
                }
            ],
            "name": "handleApproval",
            "outputs": [],
            "stateMutability": "nonpayable",
            "type": "function"
        }],
        params:{
            _token: "0x0000000000000000000000000000000000001010",
            _numTokens: "100"
        },
        msgValue: Moralis.Units.ETH()
    }

    await Moralis.executeFunction(options);
}

document.getElementById("btn-login").onclick = login;
document.getElementById("btn-logout").onclick = logOut;
document.getElementById("btn-approve").onclick = approve;

image

you donโ€™t have to set this msgValue if you donโ€™t want to send ETH

You didnโ€™t pass any value to Moralis.Units.ETH() here

i did before and was still not working i changed a few things now metamask is reverting and im getting a diffrent error

i put 0 in the msgValue as i noticed that but getting this error now

image

how far does it work, does metamask pop up and you sign the transaction? does the transaction make it to the chain?

Okay i have removed the msgValue, im getting this error.

image

No it doesnt get that far im not seeing my problem at all XD

what is the chain where is that smart contract?
what version of Moralis SDK you have?

the contract is mumbai testnet and the newest version. Im thinking it is my smart contract as i have just realised that its not letting me call the function inside of remix either ima do a coupe edits not and try get it working. Thanks for your help i will get back to you if problem persists after that.

I run that code that you have and metamask opens fine for me

oh, thats strange. ??

Even the approve window ?

this is the code that I run in browser console:

await Moralis.enableWeb3()
let options = {
        contractAddress: "0x31E5066dBf561b5d57B6711029fCfF1a158cf086",
        functionName: "handleApproval",
        abi: [{
            "inputs": [
                {
                    "internalType": "contract IERC20",
                    "name": "_token",
                    "type": "address"
                },
                {
                    "internalType": "uint256",
                    "name": "_numTokens",
                    "type": "uint256"
                }
            ],
            "name": "handleApproval",
            "outputs": [],
            "stateMutability": "nonpayable",
            "type": "function"
        }],
        params:{
            _token: "0x0000000000000000000000000000000000001010",
            _numTokens: "100"
        },

    }

    await Moralis.executeFunction(options)

Must be something to do with my metamask then ill have to work it out i just tried that code in my browser and it still has the same error