You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
The first argument is name of the contract to write to and the second argument is wagmi's`useWriteContract` hook [parameters object](https://wagmi.sh/react/api/hooks/useWriteContract#parameters).
17
+
The first argument is name of the contract to write to and the second argument is starknet-react`useWriteContract` hook [parameters object](https://starknet-react.com/hooks/mutation/usecontractwrite).
14
18
15
-
To send the transaction, you can call the `writeContractAsync` function returned by the hook (which we instance as `writeYourContractAsync`). Here's an example usage:
19
+
## Usage Example
16
20
17
21
```tsx
18
22
<button
19
23
className="btn btn-primary"
20
24
onClick={async () => {
21
25
try {
22
26
awaitwriteYourContractAsync({
23
-
functionName: "setGreeting",
24
-
args: ["The value to set"],
25
-
value: parseEther("0.1"),
27
+
args: ["The new value to set"],
28
+
options: {
29
+
value: parseEther("0.1"),
30
+
},
26
31
});
27
32
} catch (e) {
28
33
console.error("Error setting greeting:", e);
@@ -33,24 +38,22 @@ To send the transaction, you can call the `writeContractAsync` function returned
33
38
</button>
34
39
```
35
40
36
-
This example sends a transaction to the `YourContract` smart contract to call the `setGreeting` function with the arguments passed in `args`. The `writeContractAsync` function (`writeYourContractAsync` instance) sends the transaction to the smart contract.
37
-
38
41
Below is the configuration for `writeContractAsync` function:
|**functionName**|`string`| Name of the function to call. |
45
-
|**args**(optional)|`unknown[]`|Array of arguments to pass to the function (if accepts any). Types are inferred from contract's function parameters. |
46
-
|**value** (optional) |`bigint`| Amount of ETH to send with the transaction (for payable functions only). |
47
-
|**onBlockConfirmation** (optional) |`function`| Callback function to execute when the transaction is confirmed.|
48
-
|**blockConfirmations** (optional) |`number`| Number of block confirmations to wait for before considering transaction to be confirmed (default : 1). |
47
+
|**contractName**|`string`| Name of the contract to write to.|
48
+
|**functionName**|`string`|Name of the function to call.|
49
+
|**args** (optional) |`unknown[]`|Array of arguments to pass to the function (if any). Types are inferred from the contract's function parameters.|
50
+
|**options** (optional) |`objet`| Additional options for the transaction (e.g., value for payable functions).|
51
+
49
52
50
-
You can also pass other arguments accepted by [writeContractAsync from wagmi](https://wagmi.sh/react/api/hooks/useWriteContract#mutate-async).
53
+
You can also pass other arguments accepted by [writeContractAsync from starknet-react](https://starknet-react.com/hooks/mutation/usecontractwrite).
51
54
52
55
## Return Values
53
56
54
57
-`writeContractAsync` function sends the transaction to the smart contract.
55
58
-`isMining` property indicates whether the transaction is currently being mined.
56
-
- The extended object includes properties inherited from wagmi useWriteContract. You can check the [useWriteContract return values](https://wagmi.sh/react/api/hooks/useWriteContract#return-type)documentation to check the types.
59
+
- The extended object includes properties inherited from the useContractWrite hook from starknet-react. You can check the [useWriteContract return values](https://wagmi.sh/react/api/hooks/useWriteContract#return-type)for the types.
0 commit comments