0

Our app is using React + Wagmi + prepare hooks.

One MetaMask user had an issue where their transaction completed successfully, but DoThisThing was never called. Code is simplified, but wondering if anyone has experienced Wagmi + MetaMask broadcasting a successful transaction while not returning the hash and/or isSuccess. Is this possible?

const { data, isSuccess, sendTransaction } = useSendTransaction(config);

...

useEffect(() => {
  if (isSuccess && data?.hash) {
    DoThisThing({ hash: data.hash });
  }
}, [data?.hash, isSuccess]);

1 Answer 1

0

Wagmi useSendTransaction() version 1.4.3 you can use callback function onSuccess() like this:

const { data, isSuccess, sendTransaction } = useSendTransaction({
    ...config,
    onSuccess(data) {
       DoThisThing({ hash: data.hash });
    },
});

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.