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 Aug 5, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: src/app/react/v5/migrate/contracts/page.mdx
+92-2Lines changed: 92 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -78,5 +78,95 @@ function App() {
78
78
}
79
79
```
80
80
81
-
As you can see from the example above, we introduced the hook [`useReadContract`](/references/typescript/v5/useReadContract) in v5. You should use it to perform any contract "read".
82
-
It is the perfect replacement for the old chunky React hooks from v4.
81
+
As you can see from the example above, we introduced the hook [`useReadContract`](/references/typescript/v5/useReadContract) in v5.
82
+
You should use it to perform any contract "read" in your React app.
83
+
It is the perfect replacement for the old chunky React hooks from v4.
84
+
85
+
The formula for reading a contract state is:
86
+
```
87
+
useReadContract + <the read contract method>
88
+
```
89
+
90
+
#### If the extension you are looking for is not included in the SDK
91
+
You can always use the function signature with `useReadContract` (It's also typesafe)
In v5, you can utilize the following hooks for writing to contracts: [`useSendTransaction`](/references/typescript/v5/useSendTransaction) and [`useSendAndConfirmTransaction`](/references/typescript/v5/useSendAndConfirmTransaction).
109
+
The main difference between the 2 hooks is that `useSendTransaction` will mark the request as "complete" once the transaction is sent,
110
+
while `useSendAndConfirmTransaction` will wait until the transaction is included in the blockchain.
111
+
112
+
Given the task of claiming an NFT from an NFT Drop collection, let's compare the code between the SDK v4 and v5
0 commit comments