executeFunction dont work

i want to test some send function in my dapp but stil having a error:
moralis.js:6910 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘apply’)
at Function. (moralis.js:6910)
at tryCatch (moralis.js:44057)
at Generator.invoke [as _invoke] (moralis.js:44288)
at Generator.next (moralis.js:44113)
at asyncGeneratorStep (moralis.js:28197)
at _next (moralis.js:28219)

async function donate() {
    const option = {
      chain: "bsc testnet",
      address: "0x0A40eB3A8CdC34D594FdA5c9CC8aBDF658711B31",
      function_name: "donate",
      abi: ABI,
    }
    const donate = await Moralis.executeFunction(option);
    console.log(donate)
}

Hey @kcastroverde executeFunction doesn’t have chain option, just make sure your Metamask is on the right chain. Also recommend you to differentiate the name of your function and variable instead of having both donate. I’m afraid JS might be confused when running the code.

still not working


const serverUrl = "https://ojvfpgjsby8w.usemoralis.com:2053/server";
const appId = '3iJu6wQtjzWpWdHpE6A7ActsKJ4oT84wx5bIMV5v';
Moralis.start({ serverUrl, appId });

const ABI = [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Donators","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DonatorsLengt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"donate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getTotalDonations","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getvalue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}];

window.user = null



window.onload = async() => {
  if(!window.user){
    const currentUser = Moralis.User.current()
    console.log(currentUser)
    try { 
    window.user = await Moralis.Web3.authenticate({
      signingMessage:"CryptoSlayer Donation Round",
      })
      
      
      document.getElementById('btn-login').innerHTML = window.user.get('ethAddress');
      const balance = await Moralis.Web3API.account.getNativeBalance ({chain: 'bsc testnet'});
      
      document.getElementById('resultNative').innerHTML = `Balance: ${balance.balance/10**18} BNB`
      document.getElementById('resultNative').removeAttribute('style')
      localStorage.setItem('UserAddress', user.get('ethAddress'))
      DonatorsLengt()
      getValue()
    
  } catch (error) {
    console.error(error)
  } 
  }else {
    alert('install metamask')

  }
}



async function login() {
  if (!window.user){
    try {
      window.user = await Moralis.authenticate({
        signingMessage:"CryptoSlayer Donation Round",
        })
      
        document.getElementById('btn-login').innerHTML = user.get('ethAddress');
        const balance = await Moralis.Web3API.account.getNativeBalance ({chain: 'bsc testnet'});
        
        document.getElementById('resultNative').innerHTML = `Balance:  ${balance.balance/10**18} BNB`
        document.getElementById('resultNative').removeAttribute('style')
        localStorage.setItem('UserAddress', user.get('ethAddress'))
        DonatorsLengt()
        getValue()

 
    
    } catch (error) {
      console.error(error)
    } 
  }else {
      alert('metamask already login')
    }
  }
  
  
  
  async function getValue() {
        const option = {
          chain: "bsc testnet",
          address: "0x0A40eB3A8CdC34D594FdA5c9CC8aBDF658711B31",
          function_name: "getvalue",
          abi: ABI,
        } 
        const getvalue = await Moralis.Web3API.native.runContractFunction(option);
        return document.getElementById('value').innerHTML = `${getvalue/10**18}BNB`
  }
    
  


async function DonatorsLengt() {
  const option2 = {
    chain: "bsc testnet",
    address: "0x0A40eB3A8CdC34D594FdA5c9CC8aBDF658711B31",
    function_name: "DonatorsLengt",
    abi: ABI,
  }
  const DonatorsLengt = await Moralis.Web3API.native.runContractFunction(option2);
    return document.getElementById('count').innerHTML = `Donadores: ${DonatorsLengt}/1000`
}



/* this code still having the same trouble  */
async function donate() {
  const web3 = await Moralis.enableWeb3();

    const option = {
      contractAddress: "0x0A40eB3A8CdC34D594FdA5c9CC8aBDF658711B31",
      functionName: "donate",
      abi: window.ABI,
      params: {
        amount: "200000000000000000",
      }
    }
    const plsdonate = await Moralis.executeFunction(option);
}
  

my html

<!doctype html>
<html lang="es">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

    <title>Donadores</title>
    <script src="https://unpkg.com/moralis/dist/moralis.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
 
    
  
  </head>
  <body>
    <div class="container" style="margin: 20px; text-align: end; font-size: 25px;">
      <button onclick="login()" id="btn-login">Metamask Login</button>
      <span id="resultNative" style="visibility: hidden;"></span>
    </div>

   <div class="container" style="border: solid black 1px; height: 80vh;">
    <div class="container" style=" text-align: center; margin-top: 100px;">
      <h1 style="font-size: 80px;">Ronda de donadores</h1>
    </div>
    <div style="text-align: center; margin-top: 50px;">
      <h2 id="count">Donadores: -- </h2>
    </div>
    <div class="container text-center" style="padding: 10px;">
      <button onclick="runcode()" id="value"  class="btn btn-primary" style="font-size: 30px;">Precio -- BNB</button>
    </div>

    <div class="container" style="font-size: 20px; margin-top: 30px;">
      <ul>
        <p>Que obtenemos al donar</p>
        <li>El Rol de SLAYER PILAR en Discord</li>
        <li>Un NFT único que no se conseguirá nunca más </li>
        <li>whitelist de NFT. </li>
        <li>whitelist de Token</li>
      </ul>
    </div>
   </div>
    

            
 

    <!-- Optional JavaScript; choose one of the two! -->

    <!-- Option 1: Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

    <!-- Option 2: Separate Popper and Bootstrap JS -->
    <!--
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
    -->

    <script type="text/javascript" src="./main.js"></script>

  </body>
</html>

already resolve but hace some gas troubles
thanks