@d9-network/spec 0.1.1 → 1.0.0

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 ADDED
@@ -0,0 +1,92 @@
1
+ # @d9-network/spec
2
+
3
+ TypeScript SDK for D9 blockchain interactions, wallet cryptography, and chain specifications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @d9-network/spec
9
+ # or
10
+ bun add @d9-network/spec
11
+ # or
12
+ pnpm add @d9-network/spec
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { createD9Client } from "@d9-network/client";
19
+ import { generateMnemonic, createAccountFromMnemonic } from "@d9-network/spec";
20
+
21
+ // Create client
22
+ const client = createD9Client();
23
+
24
+ // Generate a new wallet
25
+ const mnemonic = generateMnemonic();
26
+ const account = createAccountFromMnemonic(mnemonic);
27
+ console.log("Address:", account.address);
28
+
29
+ // Query USDT balance
30
+ const result = await client.inkSdk.usdt.query("PSP22::balance_of", {
31
+ origin: account.address,
32
+ args: { owner: account.address },
33
+ });
34
+
35
+ if (result.success) {
36
+ console.log("Balance:", result.value);
37
+ }
38
+ ```
39
+
40
+ ## Features
41
+
42
+ - **Wallet Management**: HD wallet derivation, SR25519 signing, SS58 encoding
43
+ - **Contract Descriptors**: Type-safe descriptors for D9 smart contracts
44
+ - **Chain Specifications**: D9 network metadata and type definitions
45
+ - **Utility Functions**: Balance formatting, address validation
46
+ - **Constants**: D9 chain constants (SS58 prefix, decimals, etc.)
47
+
48
+ ## API Overview
49
+
50
+ ### Wallet
51
+
52
+ | Export | Description |
53
+ | --------------------- | ----------------------------------- |
54
+ | `generateMnemonic` | Generate BIP39 mnemonic |
55
+ | `createSR25519Wallet` | Create SR25519 wallet from mnemonic |
56
+ | `deriveKeyPair` | Derive key pair with HD path |
57
+
58
+ ### Utilities
59
+
60
+ | Export | Description |
61
+ | ---------------- | -------------------------------- |
62
+ | `formatBalance` | Format token balance for display |
63
+ | `parseAmount` | Parse balance string to bigint |
64
+ | `isValidAddress` | Validate SS58 address |
65
+
66
+ ### Constants
67
+
68
+ | Export | Description |
69
+ | ---------------- | ------------------------------ |
70
+ | `D9_SS58_PREFIX` | D9 network SS58 prefix (9) |
71
+ | `D9_DECIMALS` | D9 token decimals (12) |
72
+ | `D9_SYMBOL` | D9 token symbol ("D9") |
73
+ | `USDT_DECIMALS` | USDT token decimals (2) |
74
+ | `USDT_SYMBOL` | USDT token symbol ("USDT") |
75
+
76
+ ### Contract Descriptors
77
+
78
+ Pre-built descriptors for D9 smart contracts (from `@polkadot-api/descriptors`):
79
+
80
+ - `usdt` - USDT PSP22 token
81
+ - `burnManager` - Token burning mechanism
82
+ - `miningPool` - Mining reward contracts
83
+
84
+ ## Documentation
85
+
86
+ For complete documentation, examples, and API reference, visit:
87
+
88
+ - [D9 SDK Documentation](https://docs.d9network.com/docs/sdk/spec/overview)
89
+
90
+ ## License
91
+
92
+ MIT