This is the HTML file
<html>
<head>
<!-- Moralis SDK code -->
<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>
<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