How to use KleverChain SDK
Getting started with the KleverChain SDK
Basic usage
There are two ways to make a contract call: you can call only one method passing the user data plus the contract data or you can create an instance of an account.
Sender address and private key is required in all transactions.
With a simple call:
With an account instance:
Transactions
All available transactions:
ID | Type |
---|---|
0 | Transfer |
1 | Create Asset |
2 | Create Validator |
3 | Validator Config |
4 | Freeze |
5 | Unfreeze |
6 | Delegate |
7 | Undelegate |
8 | Withdraw |
9 | Claim |
10 | Unjail |
11 | Asset Trigger |
12 | Set Account Name |
13 | Proposal |
14 | Vote |
15 | Config ITO Prices |
16 | Set ITO Prices |
17 | Buy |
18 | Sell |
19 | Cancel Market Order |
20 | Create Marketplace |
21 | Config Marketplace |
22 | Update Account Permission |
Usage Inside a Context
If you want a global instance of your account to use throughout your app, you can create a custom hook to help you with that.
Using React as an example, you can create a MyCustomHook.tsx
file and create your provider as follows:
And wrap your entire App.tsx
in it:
With that, you can use it on any child component you want, without the need to instantiate an account every time:
The same pattern of global provider can be achieved in any framework you want, not only React.
Last updated