Hello folks, I need your help.
I have created a browser game and am now stuck on the automatic payout of the tokens.
My game is about renewable energies
So far the following is possible:
- The user can transfer tokens that he previously bought into the game
 - He can then afford the buildings that produce electricity, which in turn can then be exchanged for tokens.
 - Now I have the right ABI but no idea where and how I can integrate it into my JS file so that when I click Payout, the token from Wallet X is paid out to the user without me having to do anything.
 
I would be really grateful for help.
// MORALIS CODE
(async function(){
const serverUrl = "https://34qebmelnk4r.usemoralis.com:2053/server"; //Server url from moralis.io
const appId = "Kp7tgfuyUCx0l21P63ppK15g9qZQdPhu0s1erBja"; // Application id from moralis.io
  await Moralis.start({serverUrl, appId});
  await Moralis.enableWeb3();
})()
        async function login() {
            try {
                let currentUser = Moralis.User.current();
                if (!currentUser) {
                    if (typeof screen.orientation === 'undefined') { 
                        
                        // await Moralis.authenticate({ provider: "walletconnect" })
                        
                        const user = await Moralis.authenticate({ 
                            provider: "walletconnect", 
                            signingMessage: "my new custom message: hello",
                            mobileLinks: [
                            "rainbow",
                            "metamask",
                            "argent",
                            "trust",
                            "imtoken",
                            "pillar",
                            ] 
                        })
                    }else{
                        currentUser = await Moralis.authenticate({ signingMessage: "PowerCoin P2E Game" });
  //PHP ADDON
var http = new XMLHttpRequest();
var params = 'account=' +Moralis.User.current().get('ethAddress');
http.open("POST", "***", true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
  }
};
http.send(params);
  //PHP ADDON ENDE						
                    }
                    checkUser();
                }
            } catch (error) {
                console.log(error);
            }
        }
        logout = async () => {
            await Moralis.User.logOut();
            checkUser();
        }
		
		function checkUser() {
            currentUser = Moralis.User.current();
            if (currentUser) {
                document.getElementById("login_button").style.display = "none";
                document.getElementById("logout_button").style.display = "block";
                document.getElementById("content").style.display = "block";
            } else {
                document.getElementById("login_button").style.display = "block";
                document.getElementById("logout_button").style.display = "none";
                document.getElementById("content").style.display = "none";
            }
        }		
async function transferNative(){
  const address = document.getElementById('native-address').value;
  const amount = document.getElementById('native-amount').value;
  // sending 0.5 ETH
  const options = {
    type: "native", 
    amount: Moralis.Units.ETH(amount), 
    receiver: address
  }
  let result = await Moralis.transfer(options)
}
async function transferERC20(){
  const address = document.getElementById('erc20-address').value;
  const amount = document.getElementById('erc20-amount').value;
  const contract = document.getElementById('erc20-contract').value;
  const decimals = document.getElementById('erc20-decimals').value;
  
  // sending 0.5 ETH
  const options = {
    type: "erc20", 
    amount: Moralis.Units.Token(amount, decimals), 
    receiver: address,
    contractAddress: contract
  }
  let result = await Moralis.transfer(options)
  //PHP ADDON
var http = new XMLHttpRequest();
var params = 'amount='+amount;
http.open("POST", "***.php", true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    document.getElementById('erc20-amount').innerHTML = this.responseText;
	            alert(http.responseText)
  }
};
http.send(params);
var http = new XMLHttpRequest();
var params = 'address='+address;
http.open("POST", "***.php", true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    document.getElementById('erc20-address').innerHTML = this.responseText;
	            alert(http.responseText)
  }
};
http.send(params);
  //PHP ADDON ENDE  
}
document.getElementById("login_button").onclick = login;
document.getElementById("logout_button").onclick = logout;
checkUser();
// FUNCTION CLICK LISTENER
document.getElementById("transfer-native").onclick = transferNative;
document.getElementById("transfer-erc20").onclick = transferERC20;
// OLD BOOTSTRAP CODE
(function () {
  'use strict'
  feather.replace({ 'aria-hidden': 'true' })
  // Graphs
  var ctx = document.getElementById('myChart')
  // eslint-disable-next-line no-unused-vars
})()
        
      
    