Unable to use the provider and use the executeFunction

What if you try with this abi: [{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]?

This abi should have only the approve function.

Yeah than it

MoralisWeb3.js:1053 Uncaught (in promise) Error: Function does not exist in abi

It still looks like you are running different code than what you think you are running. Like in this case it looks like it tries to execute a different function and not the approve function.
What if you comment that function execution, you still get this error?
By that function execution I mean const allowance = await Moralis.executeFunction(options);

There is’nt really any other function. If i comment that function execution there is’nt any other function execution happening.
I have a doubt when we call a smart contract function which alters the state of the blockchain we will have to sign the contract before calling it right. So it should not be same as executeFunction or does the executeFunction does it internally?

The executeFunction will handle both call and send options:

it looks like this code finds the function name in the api:


const options = {
  contractAddress: "0xA794C9ee519FD31BbCE643e8D8138f735E97D1DB",
  functionName: "approve",
  abi: [{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],
  params: {spender: "0x923761B99e4b7d54E5fC33E4B6F7512f6D8a71e3", amount: 10},
};

function executeFunction2({ contractAddress, abi, functionName, params = {} } = {}) {
    const contractOptions = {};
    const functionData = abi.find(x => x.name === functionName);
    if (!functionData) throw new Error('Function does not exist in abi');
    console.log(functionName)
    }

executeFunction2(options);

I copied the start of the executeFunction form Moralis SDK, with the part where it checks the api.
And in your case you said that it generated that error with Function does not exist in abi'