@thru/thru-sdk 0.0.9 → 0.1.8

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.
Files changed (2) hide show
  1. package/README.md +44 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,45 @@
1
- whenever there are new protos
2
- - update the proto directory with new .proto files
3
- - run `pnpm --filter @thru/thru-sdk protobufs:pull`
4
- - run `pnpm --filter @thru/thru-sdk protobufs:generate`
5
- - run `pnpm --filter @thru/thru-sdk build`
1
+ # @thru/thru-sdk
6
2
 
7
- publish the package or do whatever local dev you want
3
+ Typed TypeScript/JavaScript client for talking to the Thru blockchain. It wraps the public gRPC-Web endpoints and bundles helpers for working with blocks, accounts, transactions, proofs, and typed identifiers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @thru/thru-sdk
9
+ ```
10
+
11
+ ## Basic Usage
12
+
13
+ ```ts
14
+ import { createThruClient } from '@thru/thru-sdk';
15
+
16
+ // Point at the default public alpha cluster or override with your own URL
17
+ const thru = createThruClient({
18
+ baseUrl: 'https://grpc-web.alphanet.thruput.org',
19
+ });
20
+
21
+ // Fetch the cluster height and the latest finalized block
22
+ const { finalized } = await thru.blocks.getBlockHeight();
23
+ const latestBlock = await thru.blocks.get({ slot: finalized });
24
+
25
+ // Retrieve an account by address (Base58-like strings starting with "ta")
26
+ const account = await thru.accounts.get('taExampleAddress...');
27
+
28
+ // Build, sign, and submit a transaction
29
+ const { rawTransaction, signature } = await thru.transactions.buildAndSign({
30
+ feePayer: {
31
+ publicKey: 'taFeePayerAddress...',
32
+ privateKey: feePayerSecretKeyBytes,
33
+ },
34
+ program: programIdentifierBytes,
35
+ });
36
+ await thru.transactions.send(rawTransaction);
37
+ ```
38
+
39
+ ### Modules at a Glance
40
+
41
+ - `thru.blocks` — query finalized or raw blocks and stream height information
42
+ - `thru.accounts` — fetch account state, list owned accounts, and generate create-account transactions
43
+ - `thru.transactions` — build transactions locally, sign them, submit, and inspect status
44
+ - `thru.events` / `thru.proofs` — retrieve on-chain events and generate state proofs
45
+ - `thru.helpers` — convert to/from Thru identifiers (addresses, signatures, block hashes) and derive program addresses
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thru/thru-sdk",
3
- "version": "0.0.9",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "main": "./dist/sdk.js",
6
6
  "types": "./dist/sdk.d.ts",