I received next error {“code”:141,“error”:“Function buyFreeTicket
is not read only”}
const { runContractFunction, data, error, isLoading, isFetching } =
useApiContract({
chain: “mumbai”,
address: TICKET_ADDRESS,
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, there is a react hook that should work, I don’t know it’s name
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