[SOLVED] Cannot read properties of undefined (reading 'call')

I have this error when i try to executeFunction Mint, someone can help?

// MINT FUNCTION
const mint = async () => {
const options = {
contractAddress: ContractAddress,
functionName: “mint”,
abi: Abi,
msgValue: ethers.utils.parseEther((0.05 * mintAmount).toString()).toString(),
};
console.log(options);
const transaction = await Moralis.executeFunction(options);
};

THE ERROR IN GOOGLE CHROM CONSOLE:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘call’)
at Function. (MoralisWeb3.js:1739:1)
at tryCatch (runtime.js:63:1)
at Generator.invoke [as _invoke] (runtime.js:294:1)
at Generator.next (runtime.js:119:1)
at asyncGeneratorStep (asyncToGenerator.js:5:1)
at _next (asyncToGenerator.js:27:1)
at asyncToGenerator.js:34:1
at new Promise ()
at new Wrapper (export.js:18:1)
at Function. (asyncToGenerator.js:23:1)

is web3 enabled?

the error is generated when executing Moralis.executeFunction?

I spent about 2 days to figure out what I did wrong , so let me explain here my issue and how I resolve it.
I also tried to call write function from blockchain.
So I after a lot of failed attempts I created simple contract to investigate.
Contract code

contract TestWriteContract {
address public myAddress;
function setAddress(address addressParam) public payable {
myAddress = addressParam;
}
}
React code
const writeContractProcessor = useWeb3ExecuteFunction();
const options2 = {
abi: TestWriteContract.abi, // make sure if abi set correctly in my case it returns me Cannot read properties of undefined (reading ‘call’)
contractAddress: “ContractAddress”,
functionName: “setAddress”,
msgValue:0, // make sure you set it
params: {
addressParam: “anyAddress”
}
}
await writeContractProcessor.fetch({
params: options2,
onSuccess: () => {
console.log(“Address succesful”);
},
onError: (error) => {
alert(error.data.message)
}
});
in my case I did mistake in abi param, I just set it like TestWriteContract, without .abi. actually the path to abi json.

I’m rly very confused why msgValue is not show here https://github.com/MoralisWeb3/react-moralis/search?q=useWeb3Contract
It’s insane

1 Like