How to get approval for ERC20 and call the function with a argument in the smart contract with

This is the HTML file

<html>
  <head>
    <!-- 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>
  </head>
  <body>
    <h1>Moralis Gas Stats</h1>

    <button id="btn-login">Connect</button>
    <button id="btn-approve">Approve</button>
    <!-- stats will go here -->
    <ul id="gas-stats"></ul>

    <script src="./index.js" type="module"></script>
    // connect to Moralis server // refresh stats //get stats on page load <
  </body>
</html>

This is the javascript file

import { UsdtAddress, ERC20_ABI, contractAddresss, Abi } from "./constants";
const serverUrl = "https://kbk1w9nb3qip.usemoralis.com:2053/server";
const appId = "ktAaYbPzbDwsJTbd7MIxKXZBeU8zPfGrc3T8eFkm";
Moralis.start({ serverUrl, appId });

// LOG IN WITH METAMASK
async function login() {
  let user = Moralis.User.current();
  if (!user) {
    user = await Moralis.authenticate();
  }
  console.log("logged in user:", user);
}

// LOG OUT

// bind button click handlers
document.getElementById("btn-login").onclick = login;
document.getElementById("btn-approve").onclick = getTranscation;
const USDtamount = 10;
const options = {
  chain: "0x4",
  contractAddress: UsdtAddres,
  functionName: "approve",
  abi: ERC20_ABI,
  params: { contractAddresss, USDtamount },
};
const contractOptions = {
  chain: "0x4",
  contractAddress: contractAddresss,
  functionName: "buy",
  abi: Abi,
  parans: { USDtamount },
};
async function getTranscation() {
  const tx = await Moralis.executeFunction(options);
  tx.wait(1);

  const tx2 = await Moralis.executeFunction(contractOptions);
  tx2.wait(1);
  return tx2;
}

The metamask wasn’t popping for approval, is there anything required to change in the js file

According to the general standard, the parameters expected are _spender and _value such like

params: {
    _spender: "0x.....b2FF83e1Ae",
    _value: 1000000,
}

For executeFunction, you don’t need to pass a chain such like this, the chain is determined from the current network of the connected wallet

You can also wrap all your codes in the getTranscation function in a try...catch block and log for error incase there’s any error

Thank you for your response