From a653037eedb36097dbc8ba3b9f76f559118a4159 Mon Sep 17 00:00:00 2001 From: Shiv Bhonde Date: Thu, 26 Oct 2023 20:48:42 +0530 Subject: [PATCH] add imperative writeAsync example --- docs/hooks/useScaffoldContractWrite.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/hooks/useScaffoldContractWrite.md b/docs/hooks/useScaffoldContractWrite.md index bcde460..11b8526 100644 --- a/docs/hooks/useScaffoldContractWrite.md +++ b/docs/hooks/useScaffoldContractWrite.md @@ -11,8 +11,8 @@ const { writeAsync, isLoading, isMining } = useScaffoldContractWrite({ contractName: "YourContract", functionName: "setGreeting", args: ["The value to set"], - // For payable functions, expressed in ETH - value: "0.01", + // For payable functions + value: parseEther("0.1"), // The number of block confirmations to wait for before considering transaction to be confirmed (default : 1). blockConfirmations: 1, // The callback function to execute when the transaction is confirmed. @@ -24,10 +24,18 @@ const { writeAsync, isLoading, isMining } = useScaffoldContractWrite({ To send the transaction, you can call the `writeAsync` function returned by the hook. Here's an example usage: -```ts +```tsx ``` This example sends a transaction to the `YourContract` smart contract to call the `setGreeting` function with the arguments passed in `args`. The `writeAsync` function sends the transaction to the smart contract, and the `isLoading` and `isMining` properties indicate whether the transaction is currently being processed by the network. + +It is also possible to pass arguments imperatively to the `writeAsync` function: + +```tsx + +```