@d9-network/ink 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,82 @@
1
+ # @d9-network/ink
2
+
3
+ Type-safe SDK for interacting with ink! smart contracts on the D9 blockchain network.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @d9-network/ink
9
+ # or
10
+ bun add @d9-network/ink
11
+ # or
12
+ pnpm add @d9-network/ink
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { createD9InkSdk } from "@d9-network/ink";
19
+ import { usdt } from "@d9-network/spec"; // Contract descriptor
20
+
21
+ // Create SDK instance
22
+ const sdk = await createD9InkSdk({
23
+ endpoint: "wss://mainnet.d9network.com:40300",
24
+ });
25
+
26
+ // Create contract instance
27
+ const contract = sdk.createContract(usdt, "cXYZ...contractAddress");
28
+
29
+ // Query contract state
30
+ const result = await contract.query("PSP22::balance_of", {
31
+ origin: "cXYZ...yourAddress",
32
+ args: { owner: "cXYZ...targetAddress" },
33
+ });
34
+
35
+ if (result.success) {
36
+ console.log("Balance:", result.value);
37
+ }
38
+ ```
39
+
40
+ ## Features
41
+
42
+ - **Type-safe contract interactions**: Full TypeScript inference for message parameters and return types
43
+ - **Automatic gas estimation**: Dry-run execution before submitting transactions
44
+ - **AccountId with D9 prefix**: All addresses automatically use D9 SS58 prefix (9)
45
+ - **Event parsing**: Type-safe decoding of contract events
46
+ - **Comprehensive error handling**: Detailed error types for debugging
47
+
48
+ ## API Overview
49
+
50
+ ### SDK Creation
51
+
52
+ | Export | Description |
53
+ | --------------------- | -------------------------- |
54
+ | `createD9InkSdk` | Create ink SDK instance |
55
+ | `createD9InkContract` | Create individual contract |
56
+
57
+ ### Encoding/Decoding
58
+
59
+ | Export | Description |
60
+ | -------------------------- | --------------------------- |
61
+ | `encodeCall` | Encode contract call |
62
+ | `decodeContractCallResult` | Decode contract call result |
63
+ | `InkCodecs` | Pre-defined SCALE codecs |
64
+
65
+ ### Error Types
66
+
67
+ | Export | Description |
68
+ | --------------- | --------------------- |
69
+ | `ContractError` | Base contract error |
70
+ | `DecodeError` | Result decoding error |
71
+ | `LangError` | ink! language error |
72
+ | `NetworkError` | RPC/WebSocket error |
73
+
74
+ ## Documentation
75
+
76
+ For complete documentation, examples, and API reference, visit:
77
+
78
+ - [D9 SDK Documentation](https://docs.d9network.com/docs/sdk/ink/overview)
79
+
80
+ ## License
81
+
82
+ MIT