I have this function to swap token on panckeswap
// Buy and Sell
async function buyToken(){
const buyT = document.getElementById('buyAmount').value;
const buy = Moralis.Units.Token(buyT, "18");
const to = user.get("ethAddress");
const deadline = Date.now() + 10000;
const optionsBuy = {
chain: "bsc",
address: '0x10ed43c718714eb63d5aa57b78b54704e256024e',
functionName: "swapExactETHForTokensSupportingFeeOnTransferTokens",
abi: routerAbi,
msgValue: buy,
params: {amountOutMin:0, path:['0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c', '0x42981d0bfbaf196529376ee702f2a9eb9092fcb5'], to:to, deadline: deadline }
};
const buy = await Moralis.executeFunction(optionsBuy);
const result = await buy.wait(2);
console.log(result)
}
When I run the function I get this error:
Uncaught (in promise) Error: invalid contract address or ENS name (argument="addressOrName", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.6.0)