Skip to content

Commit 2189b0e

Browse files
committed
fix injective example README
1 parent 67a7b0f commit 2189b0e

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

examples/injective/README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Injective React Example
2+
13
## Getting Started
24

35
First, install the packages and run the development server:
@@ -10,7 +12,50 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the
1012

1113
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
1214

13-
## Learn More
15+
## Overview
16+
17+
This example demonstrates how to build a React application that interacts with the Injective blockchain. By following this guide, you will learn how to set up a development environment, use React hooks, and integrate various Cosmos ecosystem tools to enhance your application.
18+
19+
## Query and Tx Hooks
20+
21+
This example uses the query hooks(e.g. useGetBalance) and tx hooks(e.g. useSend) from the `injective-react` package to interact with the Injective blockchain. These hooks allow you to query data from the blockchain and send transactions to the blockchain.
22+
23+
```js
24+
import { useDelegate } from "injective-react/cosmos/staking/v1beta1/tx.rpc.func";
25+
import { useGetValidators } from "injective-react/cosmos/staking/v1beta1/query.rpc.func";
26+
27+
const {
28+
data,
29+
isSuccess: isGetValidatorsDone,
30+
isLoading: isGetValidatorsLoading,
31+
} = useGetValidators({
32+
request: {
33+
status: "BOND_STATUS_BONDED",
34+
},
35+
options: {
36+
context: defaultContext,
37+
enabled: !validatorAddress,
38+
},
39+
rpcClient,
40+
});
41+
42+
const { mutate: delegate, isSuccess: isDelegateSuccess } = useDelegate({
43+
clientResolver: signingClient,
44+
options: {
45+
context: defaultContext,
46+
onSuccess: (data: any) => {
47+
console.log("onSuccess", data);
48+
},
49+
onError: (error) => {
50+
console.log("onError", error);
51+
},
52+
},
53+
});
54+
```
55+
56+
For more information on how to use these hooks, please refer to the [injective-react](https://github.com/cosmology-tech/interchainjs/tree/main/libs/injective-react)
57+
58+
## Learn More
1459

1560
### Chain Registry
1661

0 commit comments

Comments
 (0)