I have created a handler to try to use the wagmi getter function call.

const handleContractReadCurrentDuel = () => {
    const { data: duel } = useContractRead({
      address: configBlockchain.gameContract,
      abi: GAME,
      functionName: "currentDuel",
      args: [address],
      async onSuccess(data) {

        console.log('funcion currentDuel', data);


   return duel;

I want to do it in several places in my application but it doesn't allow me to do it. It only lets me call it at the top and gives me the following error:

Gives this error React Hook "useContractRead" is called in function "handleContractReadCurrentDuel" that is neither a React function component nor a custom React Hook function.

So, if I want to make more than one call to the same function, how do I do it?

2 Answers 2


To read the contract's updated data in each call, you can use refetch function from useContractRead.

 const { refetch: refetchProjects } = useContractRead({
    address: contractAddress,
    abi: abi.abi,
    functionName: "getAllProjects",
    walletClient: walletClient,
    onSuccess(data) {
    onError(error) {
      showAlert("Error", error);

Obs: you don't need to create the handleContractReadCurrentDuel arrow function.


I encountered this issue and the wagmi react hooks gave me headaches as I was working with dynamic arguments. I ended up using the wagmi core actions and they worked just fine. You might have a little issue with the build but I already explained the solution in one of my other previous answers.Here is the link to the wagmi core actions

  • The link doesn't work. Please, make sure the answer could be used independently if the link is down.
    – Ismael
    Nov 21, 2023 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.