[SOLVED] useApiContract Error

I received next error {“code”:141,“error”:“Function buyFreeTicket is not read only”}
const { runContractFunction, data, error, isLoading, isFetching } =
chain: “mumbai”,
functionName: “buyFreeTicket”,
abi: TicketContract.abi,
params: { amount: parseInt(ticketsAmount) },
What does it mean is not read only?

For a write function you have to make a transaction on chain, you will have to sign the transaction and to send it. For read only functions you can query the blockchain without sending a transaction.

Hmm I thought useApiContract would open metamask and ask me to approve the transaction.

Is there is any hook to use with write functions?

If you are using react it should be a way to do it with another react hook

Yes react. so one of https://github.com/MoralisWeb3/react-moralis would work , right?

Yes, there is a react hook that should work, I don’t know it’s name

1 Like

You can use useWeb3ExecuteFunction.

1 Like

Yeah mate, I already did it, thanks anyway. cool. After cryptoKid reply, I just did research by “write contract function” in this forum