Skip to content

Return useTransactor's return value in useScaffoldContractWrite's writeAsync function #585

Closed Answered by technophile-04
Pernick asked this question in Q&A
Discussion options

You must be logged in to vote

Just to be sure you can rely on onSucess which runs after the write is successful :

const { isSuccess, data } = useScaffoldContractWrite({
  contractName: "YourContract",
  functionName: "setGreeting",
  args: ["Hello World"],
  onSuccess(data) {
    console.log(data.hash);
    resetForm();
  },
});

Alternatively, you could also rely on isSucess variable.

It seems like I could use the return value ('0x${string}' | undefined)

The return value ('0x${string}' | undefined) is actually the transaction hash which you can access through data property returned by useScaffoldContractWrite or even onSucess function data.hash gives you same value 🙌

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Pernick
Comment options

Answer selected by technophile-04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants