Moralis SDK runContractFunction not working

I am using the latest version of Moralis and I want to execute in a smart contract function with the runContract function but it keeps throwing this error which i don’t understand. Here is the error

{"message":"Function `createMarketItem` is not read only"}

here is the code

export const listMomentForSale = async (params: paramsType) => {
	const response = await Moralis.EvmApi.utils.runContractFunction({
		abi: LIST_ITEM_TO_MARKETPLACE_ABI,
		chain: process.env.NEXT_PUBLIC_CHAINID,
		address: process.env.NEXT_PUBLIC_CONTRACT_ADDRESS,
		functionName: "createMarketItem",
		params: { ...params },
	});
	return response.result;
};

example params which i am passing to the function

const params = {
			nftContract: address,
			price: 1,
			tokenId:88888,
		};

As the error says, runContractFunction run a given function of a contract abi and retrieve readonly data.. Can only be used to execute read functions.

ookay, so does it mean that if the function is emitting an event without returning any data it won’t work

It doesn’t work with functions that performs some logics that requires gas. It works with view functions which don’t cost any gas when they’re called externally by a user.