@rialo/ts-cdk 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -24
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -28,14 +28,14 @@ const isValid = keypair.verify(message, signature);
|
|
|
28
28
|
### Connect to the blockchain
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
|
-
import { createRialoClient,
|
|
31
|
+
import { createRialoClient, RIALO_DEVNET_CHAIN } from "@rialo/ts-cdk";
|
|
32
32
|
|
|
33
|
-
const client = createRialoClient(
|
|
33
|
+
const client = createRialoClient({ chain: RIALO_DEVNET_CHAIN });
|
|
34
34
|
|
|
35
35
|
// Query blockchain
|
|
36
36
|
const balance = await client.getBalance(keypair.publicKey);
|
|
37
37
|
const height = await client.getBlockHeight();
|
|
38
|
-
const
|
|
38
|
+
const chainId = client.getChainIdentifier();
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
### Build and send a transaction
|
|
@@ -43,11 +43,8 @@ const blockhash = await client.getLatestBlockhash();
|
|
|
43
43
|
```typescript
|
|
44
44
|
import { TransactionBuilder, transferInstruction } from "@rialo/ts-cdk";
|
|
45
45
|
|
|
46
|
-
//
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
// transaction creation time
|
|
50
|
-
const txCreationTime = BigInt(Date.now());
|
|
46
|
+
// transaction valid from
|
|
47
|
+
const validFrom = BigInt(Date.now());
|
|
51
48
|
|
|
52
49
|
// Create transfer instruction
|
|
53
50
|
const transfer = transferInstruction(
|
|
@@ -59,8 +56,7 @@ const transfer = transferInstruction(
|
|
|
59
56
|
// Build and sign transaction
|
|
60
57
|
const tx = TransactionBuilder.create()
|
|
61
58
|
.setPayer(keypair.publicKey)
|
|
62
|
-
.
|
|
63
|
-
.setTxCreationTime(txCreationTime)
|
|
59
|
+
.setValidFrom(validFrom)
|
|
64
60
|
.addInstruction(transfer)
|
|
65
61
|
.build();
|
|
66
62
|
|
|
@@ -96,7 +92,7 @@ const restoredKeypair = await restored.toKeypair();
|
|
|
96
92
|
Ed25519 cryptographic primitives for key management and signing.
|
|
97
93
|
|
|
98
94
|
```typescript
|
|
99
|
-
import { Keypair, PublicKey, Signature
|
|
95
|
+
import { Keypair, PublicKey, Signature } from "@rialo/ts-cdk";
|
|
100
96
|
|
|
101
97
|
// Generate random keypair
|
|
102
98
|
const keypair = Keypair.generate();
|
|
@@ -112,11 +108,8 @@ const bytes = pubkey.toBytes();
|
|
|
112
108
|
// Signature operations
|
|
113
109
|
const sig = Signature.fromBytes(signatureBytes);
|
|
114
110
|
|
|
115
|
-
//
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
// txCreationTime for transactions
|
|
119
|
-
const txCreationTime = BigInt(Date.now());
|
|
111
|
+
// validFrom for transactions
|
|
112
|
+
const validFrom = BigInt(Date.now());
|
|
120
113
|
```
|
|
121
114
|
|
|
122
115
|
### Transactions
|
|
@@ -147,8 +140,7 @@ const instruction: Instruction = {
|
|
|
147
140
|
// Build transaction
|
|
148
141
|
const tx = TransactionBuilder.create()
|
|
149
142
|
.setPayer(payerPublicKey)
|
|
150
|
-
.
|
|
151
|
-
.setTxCreationTime(txCreationTime)
|
|
143
|
+
.setValidFrom(validFrom)
|
|
152
144
|
.addInstruction(instruction)
|
|
153
145
|
.build();
|
|
154
146
|
|
|
@@ -168,18 +160,31 @@ const bytes = signed.serialize();
|
|
|
168
160
|
Communicate with Rialo blockchain nodes.
|
|
169
161
|
|
|
170
162
|
```typescript
|
|
171
|
-
import {
|
|
163
|
+
import {
|
|
164
|
+
createRialoClient,
|
|
165
|
+
getDefaultRialoClientConfig,
|
|
166
|
+
RIALO_DEVNET_CHAIN,
|
|
167
|
+
RIALO_MAINNET_CHAIN
|
|
168
|
+
} from "@rialo/ts-cdk";
|
|
169
|
+
|
|
170
|
+
// Using preset chain configurations
|
|
171
|
+
const client = createRialoClient({ chain: RIALO_DEVNET_CHAIN });
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
// Using getDefaultRialoClientConfig helper
|
|
174
|
+
const config = getDefaultRialoClientConfig('mainnet');
|
|
175
|
+
const mainnetClient = createRialoClient({
|
|
176
|
+
...config,
|
|
177
|
+
transport: {
|
|
178
|
+
timeout: 30000,
|
|
179
|
+
maxRetries: 3,
|
|
180
|
+
}
|
|
176
181
|
});
|
|
177
182
|
|
|
178
183
|
// Query methods
|
|
179
184
|
const balance = await client.getBalance(publicKey);
|
|
180
185
|
const accountInfo = await client.getAccountInfo(publicKey);
|
|
181
186
|
const blockHeight = await client.getBlockHeight();
|
|
182
|
-
const
|
|
187
|
+
const chainId = client.getChainIdentifier();
|
|
183
188
|
const txInfo = await client.getTransaction(signature);
|
|
184
189
|
|
|
185
190
|
// Send transactions
|
|
@@ -303,7 +308,6 @@ import {
|
|
|
303
308
|
PUBLIC_KEY_LENGTH, // 32
|
|
304
309
|
SECRET_KEY_LENGTH, // 32
|
|
305
310
|
SIGNATURE_LENGTH, // 64
|
|
306
|
-
BLOCKHASH_LENGTH, // 32
|
|
307
311
|
} from "@rialo/ts-cdk";
|
|
308
312
|
```
|
|
309
313
|
|
package/package.json
CHANGED