@beclab/olaresid 0.1.12 → 0.2.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.
Files changed (182) hide show
  1. package/CLI-TREE.md +107 -0
  2. package/CLI.md +122 -1329
  3. package/README.md +30 -12
  4. package/SDK-TREE.md +151 -0
  5. package/TAG.md +95 -41
  6. package/config.json +6 -4
  7. package/dist/abi/TerminusDIDQueryABI.d.ts +397 -0
  8. package/dist/abi/TerminusDIDQueryABI.d.ts.map +1 -0
  9. package/dist/abi/TerminusDIDQueryABI.js +519 -0
  10. package/dist/abi/TerminusDIDQueryABI.js.map +1 -0
  11. package/dist/business/index.d.ts +1 -1
  12. package/dist/business/index.d.ts.map +1 -1
  13. package/dist/business/index.js +11 -24
  14. package/dist/business/index.js.map +1 -1
  15. package/dist/business/tag-context.d.ts +1 -0
  16. package/dist/business/tag-context.d.ts.map +1 -1
  17. package/dist/business/tag-context.js +13 -7
  18. package/dist/business/tag-context.js.map +1 -1
  19. package/dist/cli.js +238 -107
  20. package/dist/cli.js.map +1 -1
  21. package/dist/config/index.d.ts +16 -4
  22. package/dist/config/index.d.ts.map +1 -1
  23. package/dist/config/index.js +28 -14
  24. package/dist/config/index.js.map +1 -1
  25. package/dist/domain/core.d.ts +65 -0
  26. package/dist/domain/core.d.ts.map +1 -0
  27. package/dist/domain/core.js +317 -0
  28. package/dist/domain/core.js.map +1 -0
  29. package/dist/domain/index.d.ts +104 -57
  30. package/dist/domain/index.d.ts.map +1 -1
  31. package/dist/domain/index.js +188 -428
  32. package/dist/domain/index.js.map +1 -1
  33. package/dist/domain/types.d.ts +56 -0
  34. package/dist/domain/types.d.ts.map +1 -0
  35. package/dist/domain/types.js +3 -0
  36. package/dist/domain/types.js.map +1 -0
  37. package/dist/index.d.ts +81 -24
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +153 -143
  40. package/dist/index.js.map +1 -1
  41. package/dist/utils/crypto-utils.d.ts +124 -0
  42. package/dist/utils/crypto-utils.d.ts.map +1 -1
  43. package/dist/utils/crypto-utils.js +156 -8
  44. package/dist/utils/crypto-utils.js.map +1 -1
  45. package/dist/utils/error-parser.d.ts.map +1 -1
  46. package/dist/utils/error-parser.js +2 -1
  47. package/dist/utils/error-parser.js.map +1 -1
  48. package/dist/utils/event-parser.d.ts +161 -0
  49. package/dist/utils/event-parser.d.ts.map +1 -0
  50. package/dist/utils/event-parser.js +140 -0
  51. package/dist/utils/event-parser.js.map +1 -0
  52. package/dist/utils/tag-type-builder.d.ts +43 -0
  53. package/dist/utils/tag-type-builder.d.ts.map +1 -1
  54. package/dist/utils/tag-type-builder.js +122 -0
  55. package/dist/utils/tag-type-builder.js.map +1 -1
  56. package/dist/utils/tag-type-parser.d.ts +70 -0
  57. package/dist/utils/tag-type-parser.d.ts.map +1 -0
  58. package/dist/utils/tag-type-parser.js +190 -0
  59. package/dist/utils/tag-type-parser.js.map +1 -0
  60. package/examples/create-with-rpc-demo.ts +142 -0
  61. package/examples/fetch-all-flat-demo.ts +159 -0
  62. package/examples/fetch-by-indices-demo.ts +235 -0
  63. package/examples/fetch-domain-demo.ts +137 -0
  64. package/examples/fetch-domains-demo.ts +221 -0
  65. package/examples/frontend-demo/index.html +2 -2
  66. package/examples/frontend-demo/package-lock.json +4 -1
  67. package/examples/index.ts +3 -5
  68. package/jest.config.js +25 -0
  69. package/package.json +6 -2
  70. package/src/abi/TerminusDIDQueryABI.ts +516 -0
  71. package/src/business/index.ts +10 -33
  72. package/src/business/tag-context.ts +35 -7
  73. package/src/cli.ts +344 -121
  74. package/src/config/index.ts +34 -19
  75. package/src/domain/core.ts +382 -0
  76. package/src/domain/index.ts +271 -641
  77. package/src/domain/types.ts +59 -0
  78. package/src/index.ts +222 -207
  79. package/src/utils/crypto-utils.ts +239 -2
  80. package/src/utils/error-parser.ts +2 -1
  81. package/src/utils/event-parser.ts +353 -0
  82. package/src/utils/tag-type-builder.ts +138 -0
  83. package/src/utils/tag-type-parser.ts +246 -0
  84. package/tests/unit/crypto-utils.test.ts +338 -0
  85. package/tests/unit/ed25519-jwk.test.ts +201 -0
  86. package/tests/unit/event-parser.test.ts +690 -0
  87. package/tests/unit/generate-mnemonic.test.ts +268 -0
  88. package/tests/unit/olares-id-format.test.ts +321 -0
  89. package/tests/unit/tag-type-parser.test.ts +802 -0
  90. package/tests/unit/tag-types.test.ts +821 -0
  91. package/tsconfig.json +3 -2
  92. package/dist/abi/ABITypeABI.d.ts +0 -88
  93. package/dist/abi/ABITypeABI.d.ts.map +0 -1
  94. package/dist/abi/ABITypeABI.js +0 -382
  95. package/dist/abi/ABITypeABI.js.map +0 -1
  96. package/dist/abi/RegistryABI.d.ts +0 -77
  97. package/dist/abi/RegistryABI.d.ts.map +0 -1
  98. package/dist/abi/RegistryABI.js +0 -462
  99. package/dist/abi/RegistryABI.js.map +0 -1
  100. package/dist/tag/address.d.ts +0 -11
  101. package/dist/tag/address.d.ts.map +0 -1
  102. package/dist/tag/address.js +0 -44
  103. package/dist/tag/address.js.map +0 -1
  104. package/dist/tag/array.d.ts +0 -14
  105. package/dist/tag/array.d.ts.map +0 -1
  106. package/dist/tag/array.js +0 -72
  107. package/dist/tag/array.js.map +0 -1
  108. package/dist/tag/bool.d.ts +0 -11
  109. package/dist/tag/bool.d.ts.map +0 -1
  110. package/dist/tag/bool.js +0 -43
  111. package/dist/tag/bool.js.map +0 -1
  112. package/dist/tag/bytes.d.ts +0 -11
  113. package/dist/tag/bytes.d.ts.map +0 -1
  114. package/dist/tag/bytes.js +0 -37
  115. package/dist/tag/bytes.js.map +0 -1
  116. package/dist/tag/flarray.d.ts +0 -15
  117. package/dist/tag/flarray.d.ts.map +0 -1
  118. package/dist/tag/flarray.js +0 -81
  119. package/dist/tag/flarray.js.map +0 -1
  120. package/dist/tag/flbytes.d.ts +0 -11
  121. package/dist/tag/flbytes.d.ts.map +0 -1
  122. package/dist/tag/flbytes.js +0 -47
  123. package/dist/tag/flbytes.js.map +0 -1
  124. package/dist/tag/index.d.ts +0 -32
  125. package/dist/tag/index.d.ts.map +0 -1
  126. package/dist/tag/index.js +0 -121
  127. package/dist/tag/index.js.map +0 -1
  128. package/dist/tag/int.d.ts +0 -12
  129. package/dist/tag/int.d.ts.map +0 -1
  130. package/dist/tag/int.js +0 -49
  131. package/dist/tag/int.js.map +0 -1
  132. package/dist/tag/string.d.ts +0 -11
  133. package/dist/tag/string.d.ts.map +0 -1
  134. package/dist/tag/string.js +0 -37
  135. package/dist/tag/string.js.map +0 -1
  136. package/dist/tag/tag.d.ts +0 -67
  137. package/dist/tag/tag.d.ts.map +0 -1
  138. package/dist/tag/tag.js +0 -157
  139. package/dist/tag/tag.js.map +0 -1
  140. package/dist/tag/tuple.d.ts +0 -17
  141. package/dist/tag/tuple.d.ts.map +0 -1
  142. package/dist/tag/tuple.js +0 -162
  143. package/dist/tag/tuple.js.map +0 -1
  144. package/dist/tag/uint.d.ts +0 -12
  145. package/dist/tag/uint.d.ts.map +0 -1
  146. package/dist/tag/uint.js +0 -49
  147. package/dist/tag/uint.js.map +0 -1
  148. package/dist/test/did.d.ts +0 -2
  149. package/dist/test/did.d.ts.map +0 -1
  150. package/dist/test/did.js +0 -177
  151. package/dist/test/did.js.map +0 -1
  152. package/dist/utils/tag-abi-codec.d.ts +0 -69
  153. package/dist/utils/tag-abi-codec.d.ts.map +0 -1
  154. package/dist/utils/tag-abi-codec.js +0 -144
  155. package/dist/utils/tag-abi-codec.js.map +0 -1
  156. package/examples/crypto-utilities.ts +0 -140
  157. package/examples/ed25519-jwk.ts +0 -73
  158. package/examples/generate-mnemonic.ts +0 -149
  159. package/examples/legacy.ts +0 -33
  160. package/examples/olares-id-format.ts +0 -197
  161. package/examples/tag-builder.ts +0 -235
  162. package/examples/tag-nested-tuple.ts +0 -190
  163. package/examples/tag-simple.ts +0 -149
  164. package/examples/tag-tagger.ts +0 -217
  165. package/examples/test-nested-tuple-conversion.ts +0 -143
  166. package/examples/test-type-bytes-parser.ts +0 -70
  167. package/src/abi/ABITypeABI.ts +0 -379
  168. package/src/abi/RegistryABI.ts +0 -459
  169. package/src/tag/address.ts +0 -48
  170. package/src/tag/array.ts +0 -80
  171. package/src/tag/bool.ts +0 -43
  172. package/src/tag/bytes.ts +0 -38
  173. package/src/tag/flarray.ts +0 -99
  174. package/src/tag/flbytes.ts +0 -48
  175. package/src/tag/index.ts +0 -170
  176. package/src/tag/int.ts +0 -51
  177. package/src/tag/string.ts +0 -38
  178. package/src/tag/tag.ts +0 -229
  179. package/src/tag/tuple.ts +0 -193
  180. package/src/tag/uint.ts +0 -51
  181. package/src/test/did.ts +0 -346
  182. package/src/utils/tag-abi-codec.ts +0 -158
package/CLI.md CHANGED
@@ -1,1461 +1,254 @@
1
- # OlaresID CLI Tool
1
+ # OlaresID CLI by Scenarios
2
2
 
3
- A comprehensive command-line interface for managing OlaresID domains, RSA keys, IP records, operators, domain transfers, and cryptographic utilities.
3
+ This guide is organized by real usage goals instead of listing every command one by one.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install -g olaresid
9
- # or use npx
10
- npx olaresid <command>
8
+ npm install -g @beclab/olaresid
11
9
  ```
12
10
 
13
- ## Quick Start
11
+ ## Before You Start
14
12
 
15
13
  ```bash
16
- # Get help
17
- did-cli help
14
+ # Basic help
15
+ did-cli --help
18
16
 
19
- # Query domain information
20
- did-cli info example.olares.com
21
-
22
- # Get domain owner
23
- did-cli owner example.olares.com
24
- ```
25
-
26
- ## Commands Overview
27
-
28
- ### Query Commands
29
-
30
- #### Get Domain Metadata
31
-
32
- ```bash
33
- did-cli info <domain> [options]
34
-
35
- # Examples
36
- did-cli info example.olares.com
37
- did-cli info example.olares.com --json
38
- did-cli info example.olares.com --network sepolia
39
- ```
40
-
41
- #### Get Domain Owner
42
-
43
- ```bash
44
- did-cli owner <domain> [options]
45
-
46
- # Examples
47
- did-cli owner example.olares.com
48
- did-cli owner example.olares.com --json
49
- ```
50
-
51
- #### Check Domain Ownership
52
-
53
- ```bash
54
- did-cli is-owner <domain>
55
-
56
- # Examples
57
- export PRIVATE_KEY_OR_MNEMONIC=0x1234...
58
- did-cli is-owner example.olares.com
59
- did-cli is-owner example.olares.com --json
60
- ```
61
-
62
- ### RSA Key Management
63
-
64
- #### Generate RSA Key Pair
65
-
66
- ```bash
67
- did-cli rsa generate [options]
68
-
69
- # Examples
70
- did-cli rsa generate
71
- did-cli rsa generate --output ./my-key.pem
72
- did-cli rsa generate --key-length 4096 --output ./my-key.pem
73
- ```
74
-
75
- **Output:**
76
-
77
- - Public key: `<output-path>.pem` (PEM PKCS#8 format)
78
- - Private key: `<output-path>-private.pem` (PEM PKCS#8 format)
79
-
80
- #### Get RSA Public Key
81
-
82
- ```bash
83
- did-cli rsa get <domain> [options]
84
-
85
- # Examples
86
- did-cli rsa get example.olares.com
87
- did-cli rsa get example.olares.com --json
88
- did-cli rsa get example.olares.com --output ./public-key.pem
89
- ```
90
-
91
- #### Set RSA Public Key
92
-
93
- ```bash
94
- did-cli rsa set <domain> <pem-file>
95
-
96
- # Examples
97
- export PRIVATE_KEY_OR_MNEMONIC=0x1234...
98
- did-cli rsa set example.olares.com ./public-key.pem
99
- did-cli rsa set example.olares.com ./public-key.pem --json
17
+ # Optional: use sepolia for testing
18
+ did-cli fetch olares.com --network sepolia
100
19
  ```
101
20
 
102
- #### Remove RSA Public Key
103
-
104
- ```bash
105
- did-cli rsa remove <domain>
106
-
107
- # Examples
108
- export PRIVATE_KEY_OR_MNEMONIC=0x1234...
109
- did-cli rsa remove example.olares.com
110
- did-cli rsa remove example.olares.com --json
111
- ```
112
-
113
- ### IP Management
114
-
115
- #### Get IP Address (DNS A Record)
116
-
117
- ```bash
118
- did-cli ip get <domain> [options]
119
-
120
- # Examples
121
- did-cli ip get example.olares.com
122
- did-cli ip get example.olares.com --json
123
- ```
124
-
125
- #### Set IP Address
126
-
127
- ```bash
128
- did-cli ip set <domain> <ipv4-address>
129
-
130
- # Examples
131
- export PRIVATE_KEY_OR_MNEMONIC=0x1234...
132
- did-cli ip set example.olares.com 192.168.1.100
133
- did-cli ip set example.olares.com 192.168.1.100 --json
134
- ```
135
-
136
- #### Remove IP Address
137
-
138
- ```bash
139
- did-cli ip remove <domain>
140
-
141
- # Examples
142
- export PRIVATE_KEY_OR_MNEMONIC=0x1234...
143
- did-cli ip remove example.olares.com
144
- did-cli ip remove example.olares.com --json
145
- ```
146
-
147
- ### Subdomain Management
148
-
149
- #### Register Subdomain
21
+ Notes:
150
22
 
151
- Register a new subdomain under a parent domain. The subdomain will have its own owner (derived from a mnemonic) and inherit the parent's metadata settings.
23
+ - The default network is `mainnet`.
24
+ - Use `--json` when you want machine-readable output.
25
+ - For write operations, you usually need `PRIVATE_KEY_OR_MNEMONIC`.
152
26
 
153
- ```bash
154
- did-cli subdomain register <parent-domain> <subdomain-label> [options]
155
-
156
- # Examples
157
-
158
- # Generate a new 12-word mnemonic automatically
159
- export PRIVATE_KEY_OR_MNEMONIC=0x1234... # Parent domain owner's private key
160
- did-cli subdomain register parent.com child
161
-
162
- # Generate a 24-word mnemonic
163
- did-cli subdomain register parent.com child --words 24
164
-
165
- # Use an existing mnemonic for subdomain owner
166
- export SUBDOMAIN_OWNER_MNEMONIC="your twelve word mnemonic phrase here that will derive the keys"
167
- did-cli subdomain register parent.com child
168
-
169
- # JSON output
170
- did-cli subdomain register parent.com child --json
171
-
172
- # Use sepolia testnet
173
- did-cli subdomain register parent.com child --network sepolia
174
- ```
175
-
176
- **Important Notes:**
177
-
178
- 1. **Authentication**: You need the parent domain owner's private key or mnemonic via `PRIVATE_KEY_OR_MNEMONIC` environment variable
179
- 2. **Subdomain Owner Mnemonic**:
180
- - Set via `SUBDOMAIN_OWNER_MNEMONIC` environment variable to use an existing mnemonic
181
- - If `SUBDOMAIN_OWNER_MNEMONIC` is not set, a new one will be auto-generated and saved to `./subdomain-mnemonic.txt`
182
- - The mnemonic derives the subdomain's owner address and DID
183
- - **Save the mnemonic securely** - it's the only way to control the subdomain
184
- 3. **Full Domain**: If you register `child` under `parent.com`, the full domain will be `child.parent.com`
185
- 4. **Inheritance**: The subdomain inherits `note` and `allowSubdomain` settings from the parent
186
-
187
- **Output Example:**
188
-
189
- ```
190
- 🔑 Generated 12-word mnemonic:
191
- abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about
192
-
193
- ⚠️ IMPORTANT: Save this mnemonic securely! It controls the subdomain.
194
-
195
- 📋 Registering subdomain: child.parent.com
196
- ⏳ Submitting transaction...
197
-
198
- ✅ Subdomain registered successfully!
199
-
200
- ════════════════════════════════════════════════════════════
201
- Registration Details:
202
- ════════════════════════════════════════════════════════════
203
- Subdomain label: child
204
- Full domain name: child.parent.com
205
- Owner address: 0x9858EfFD232B4033E47d90003D41EC34EcaEda94
206
- DID: did:key:z6MkvARmXmTXnwyJz9uXbzJjEVKVb9PegegGZMqiuQQCHzo2
207
- Transaction hash: 0xabcd1234...
208
- Gas used: 150000
209
- Block number: 12345678
210
- ════════════════════════════════════════════════════════════
211
-
212
- 🔗 View on block explorer:
213
- https://sepolia-optimism.etherscan.io/tx/0xabcd1234...
214
- ```
215
-
216
- ### Domain Transfer
217
-
218
- Transfer domain ownership to a new owner. This operation involves two transactions:
219
-
220
- 1. Transfer the NFT (domain) ownership
221
- 2. Update the domain's DID to match the new owner's DID
222
-
223
- #### Transfer Domain Ownership
224
-
225
- ```bash
226
- did-cli transfer <domain> [options]
227
-
228
- # Examples
229
-
230
- # Auto-generate new owner credentials (12-word mnemonic)
231
- export PRIVATE_KEY_OR_MNEMONIC=0x1234... # Current owner's private key
232
- did-cli transfer example.com
233
-
234
- # Auto-generate with 24-word mnemonic
235
- did-cli transfer example.com --words 24
236
-
237
- # Use specific mnemonic for new owner
238
- export TO_MNEMONIC="new owner twelve word mnemonic phrase here"
239
- did-cli transfer example.com
240
-
241
- # JSON output
242
- did-cli transfer example.com --json
243
-
244
- # Use sepolia testnet
245
- did-cli transfer example.com --network sepolia
246
- ```
247
-
248
- **Important Notes:**
249
-
250
- 1. **Authentication**: You need the current owner's private key or mnemonic via `PRIVATE_KEY_OR_MNEMONIC` environment variable
251
- 2. **New Owner Mnemonic**:
252
- - Set via `TO_MNEMONIC` environment variable to use an existing mnemonic
253
- - If `TO_MNEMONIC` is not set, a new one will be auto-generated and saved to `./transfer-new-owner-mnemonic.txt`
254
- - The mnemonic derives the new owner's address and DID
255
- - **Save the new owner's mnemonic securely** - it's the only way to control the domain after transfer
256
- 3. **Two Transactions**: The operation submits two transactions to the blockchain
257
- - First: Transfer NFT ownership
258
- - Second: Update domain DID
259
- 4. **Irreversible**: Once transferred, the domain is controlled by the new owner
260
-
261
- **Output Example:**
262
-
263
- ```
264
- 🔑 Generated 12-word mnemonic for new owner:
265
- abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about
266
-
267
- ⚠️ IMPORTANT: Save this mnemonic securely! It controls the domain.
268
-
269
- 📋 Transferring domain: example.com
270
- ⏳ Submitting transactions...
271
-
272
- ✅ Domain transfer successful!
273
-
274
- Transaction Details:
275
- Domain: example.com
276
- New Owner: 0x9858EfFD232B4033E47d90003D41EC34EcaEda94
277
- New DID: did:key:z6MkvARmXmTXnwyJz9uXbzJjEVKVb9PegegGZMqiuQQCHzo2
278
- Transfer Tx: 0xabcd1234...
279
- Set DID Tx: 0xefgh5678...
280
-
281
- 🔑 New Owner Mnemonic (SAVE THIS!):
282
- abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about
283
- ```
284
-
285
- ### Crypto Utilities
286
-
287
- Generate and derive cryptographic keys from mnemonic phrases. These utilities work offline and don't require blockchain access.
288
-
289
- #### Generate Mnemonic
290
-
291
- Generate a new BIP39 mnemonic phrase. **The mnemonic is automatically saved to a file for security.**
292
-
293
- ```bash
294
- did-cli crypto generate [options]
295
-
296
- # Examples
297
- did-cli crypto generate # 12-word mnemonic (default)
298
- did-cli crypto generate --words 12 # 12-word mnemonic
299
- did-cli crypto generate --words 24 # 24-word mnemonic
300
- did-cli crypto generate --output ./my-mnemonic.txt # Custom output file
301
- did-cli crypto generate --json # JSON output
302
- ```
303
-
304
- **Output Example:**
305
-
306
- ```
307
- 🔑 Generated 12-word mnemonic
308
- 📄 Mnemonic saved to: ./mnemonic.txt
309
-
310
- ⚠️ SECURITY WARNING:
311
- • Keep this mnemonic secure! It controls all derived keys!
312
- • Store it in a safe place (paper backup, hardware wallet, etc.)
313
- • Delete the file after copying to a secure location
314
- • Command: rm ./mnemonic.txt
315
-
316
- 💡 To use the mnemonic:
317
- export MNEMONIC="$(cat ./mnemonic.txt)"
318
- ```
319
-
320
- **Note:** The default output file is `./mnemonic.txt`. Use `--output` option to specify a different location.
321
-
322
- #### Get Ethereum Address from Mnemonic
27
+ ---
323
28
 
324
- Derive an Ethereum address from a mnemonic phrase.
29
+ ## Scenario 1: Regular User Queries Olares ID Data
325
30
 
326
- **Requirements:** `MNEMONIC` environment variable must be set.
31
+ Goal: quickly see metadata and tags for a domain or Olares ID.
327
32
 
328
33
  ```bash
329
- export MNEMONIC="your twelve word mnemonic phrase here"
330
- did-cli crypto address
34
+ # Fetch complete domain data (metadata + tags)
35
+ did-cli fetch olares.com
331
36
 
332
- # JSON output
333
- did-cli crypto address --json
334
- ```
37
+ # Olares ID format is supported
38
+ did-cli fetch tw7613781@olares.com
335
39
 
336
- **Output Example:**
40
+ # JSON output for scripts
41
+ did-cli fetch olares.com --json
337
42
 
43
+ # Query owner / basic metadata
44
+ did-cli owner olares.com
45
+ did-cli info olares.com
338
46
  ```
339
- 🏠 Ethereum Address:
340
- 0x9858EfFD232B4033E47d90003D41EC34EcaEda94
341
- ```
342
-
343
- #### Get DID from Mnemonic
344
-
345
- Derive a DID (Decentralized Identifier) from a mnemonic phrase.
346
47
 
347
- **Requirements:** `MNEMONIC` environment variable must be set.
48
+ What you get:
348
49
 
349
- ```bash
350
- export MNEMONIC="your twelve word mnemonic phrase here"
351
- did-cli crypto did
50
+ - Domain metadata (name, DID, owner, allowSubdomain, etc.)
51
+ - All defined tags for that domain
52
+ - Tags without values are also returned (for example, value is `0x` and `valueFormatted` is `null`)
352
53
 
353
- # JSON output
354
- did-cli crypto did --json
355
- ```
54
+ Practical note:
356
55
 
357
- **Output Example:**
56
+ - If you are building a dashboard, prefer `fetch --json` and parse `tags` directly.
358
57
 
359
- ```
360
- 🆔 DID:
361
- did:key:z6MkvARmXmTXnwyJz9uXbzJjEVKVb9PegegGZMqiuQQCHzo2
362
- ```
58
+ ---
363
59
 
364
- #### Get EVM Private Key from Mnemonic
60
+ ## Scenario 2: Developer Registration on Olares OS (Bind RSA Key)
365
61
 
366
- Derive an EVM-compatible private key from a mnemonic phrase. **The private key is automatically saved to a file.**
62
+ Goal: bind an RSA public key to your domain so your developer identity can be verified by services.
367
63
 
368
- **Requirements:** `MNEMONIC` environment variable must be set.
64
+ Step 1: prepare signer credentials.
369
65
 
370
66
  ```bash
371
- export MNEMONIC="your twelve word mnemonic phrase here"
372
- did-cli crypto privatekey
373
-
374
- # Specify output file
375
- did-cli crypto privatekey --output ./my-private-key.txt
376
-
377
- # JSON output
378
- did-cli crypto privatekey --json
67
+ export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_DOMAIN_OWNER_PRIVATE_KEY"
68
+ # or
69
+ export PRIVATE_KEY_OR_MNEMONIC="your twelve word mnemonic phrase"
379
70
  ```
380
71
 
381
- **Output Example:**
382
-
383
- ```
384
- 🔑 EVM Private Key:
385
- 0x1ab42cc412b618bdea3a599e3c9bae199ebf030895b039e9db1e30dafb12b727
386
-
387
- 📄 Private key saved to: ./private-key.txt
388
-
389
- ⚠️ SECURITY WARNING:
390
- • Keep this private key secure! Never share it!
391
- • Delete the file after copying to a secure location
392
- • Command: rm ./private-key.txt
393
- ```
394
-
395
- **Note:** The default output file is `./private-key.txt`. Use `--output` option to specify a different location.
396
-
397
- #### Derive All Keys from Mnemonic
398
-
399
- Derive all keys (address, DID, and private key) from a mnemonic in one command. **All keys are automatically saved to a file.**
400
-
401
- **Requirements:** `MNEMONIC` environment variable must be set.
72
+ Step 2: generate key pair locally.
402
73
 
403
74
  ```bash
404
- export MNEMONIC="your twelve word mnemonic phrase here"
405
- did-cli crypto derive
406
-
407
- # Specify output file
408
- did-cli crypto derive --output ./my-keys.txt
409
-
410
- # JSON output
411
- did-cli crypto derive --json
412
- ```
413
-
414
- **Output Example:**
415
-
416
- ```
417
- 🔐 Derived Keys:
418
- Address: 0x9858EfFD232B4033E47d90003D41EC34EcaEda94
419
- DID: did:key:z6MkvARmXmTXnwyJz9uXbzJjEVKVb9PegegGZMqiuQQCHzo2
420
- Private Key: 0x1ab42cc412b618bdea3a599e3c9bae199ebf030895b039e9db1e30dafb12b727
421
-
422
- 📄 Keys saved to: ./derived-keys.txt
423
-
424
- ⚠️ SECURITY WARNING:
425
- • Keep these credentials secure! Never share them!
426
- • Delete the file after copying to a secure location
427
- • Command: rm ./derived-keys.txt
428
- ```
429
-
430
- **File Content Example:**
431
-
75
+ did-cli rsa generate --output ./developer-key.pem
432
76
  ```
433
- Ethereum Address: 0x9858EfFD232B4033E47d90003D41EC34EcaEda94
434
- DID: did:key:z6MkvARmXmTXnwyJz9uXbzJjEVKVb9PegegGZMqiuQQCHzo2
435
- Private Key: 0x1ab42cc412b618bdea3a599e3c9bae199ebf030895b039e9db1e30dafb12b727
436
- ```
437
-
438
- **Note:** The default output file is `./derived-keys.txt`. Use `--output` option to specify a different location.
439
-
440
- **Important Notes:**
441
-
442
- 1. **Offline Operation**: All crypto utilities work offline and don't require network access
443
- 2. **Deterministic**: Same mnemonic always produces the same keys
444
- 3. **BIP39 Standard**: Uses standard BIP39 mnemonic generation
445
- 4. **BIP44 Derivation**: Follows BIP44 standard for Ethereum key derivation (m/44'/60'/0'/0/0)
446
- 5. **Ed25519 for DID**: Uses Ed25519 curve for DID key generation (compatible with TermiPass)
447
- 6. **Security**:
448
- - Never share your mnemonic or private key
449
- - Store mnemonics securely (paper backup, hardware wallet, etc.)
450
- - Be cautious when using `privatekey` and `derive` commands in shared environments
451
-
452
- ### Wallet Management
453
-
454
- Manage EVM and Solana wallet addresses associated with your domain. These authenticated addresses can be used for various authorization and verification purposes.
455
77
 
456
- #### Add EVM Wallet
457
-
458
- Add an EVM wallet address to your domain's authenticated addresses.
459
-
460
- **Requirements:**
461
-
462
- - `PRIVATE_KEY_OR_MNEMONIC` environment variable (domain owner's key for signing)
463
- - `EVM_PRIVATE_KEY` environment variable (wallet to add)
78
+ Step 3: bind the public key to your domain.
464
79
 
465
80
  ```bash
466
- export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_DOMAIN_OWNER_KEY"
467
- export EVM_PRIVATE_KEY="0xWALLET_TO_ADD"
468
- did-cli wallet evm add example.com
469
-
470
- # With JSON output
471
- did-cli wallet evm add example.com --json
472
-
473
- # On sepolia testnet
474
- did-cli wallet evm add example.com --network sepolia
81
+ did-cli rsa set olares.com ./developer-key.pem
475
82
  ```
476
83
 
477
- **Output Example:**
478
-
479
- ```
480
- 💼 Adding EVM wallet to domain: example.com
481
-
482
- ✅ EVM wallet added successfully!
483
- Address: 0x9858EfFD232B4033E47d90003D41EC34EcaEda94
484
- Transaction: 0x123abc...
485
- Gas used: 150000
486
- ```
487
-
488
- **Important Notes:**
489
-
490
- - The EVM_PRIVATE_KEY is the wallet you want to add as an authenticated address
491
- - The PRIVATE_KEY_OR_MNEMONIC is your domain owner's key for authorization
492
- - The signature is valid for 1 hour from the timestamp
493
- - Duplicate addresses will be rejected with a friendly error message
494
-
495
- #### Remove EVM Wallet
496
-
497
- Remove an EVM wallet address from your domain.
498
-
499
- **Requirements:**
500
-
501
- - `PRIVATE_KEY_OR_MNEMONIC` environment variable (domain owner's key)
502
- - `EVM_PRIVATE_KEY` environment variable (wallet to remove)
84
+ Step 4: verify it.
503
85
 
504
86
  ```bash
505
- export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_DOMAIN_OWNER_KEY"
506
- export EVM_PRIVATE_KEY="0xWALLET_TO_REMOVE"
507
- did-cli wallet evm remove example.com
508
-
509
- # With JSON output
510
- did-cli wallet evm remove example.com --json
87
+ did-cli rsa get olares.com
511
88
  ```
512
89
 
513
- #### List EVM Wallets
514
-
515
- List all EVM wallet addresses associated with a domain.
516
-
517
- **No authentication required** (read-only operation)
90
+ Optional rollback:
518
91
 
519
92
  ```bash
520
- did-cli wallet evm list example.com
521
-
522
- # With JSON output
523
- did-cli wallet evm list example.com --json
93
+ did-cli rsa remove olares.com
524
94
  ```
525
95
 
526
- **Output Example:**
96
+ Practical notes:
527
97
 
528
- ```
529
- 📋 Listing EVM wallets for domain: example.com
530
- Found 2 wallet(s):
531
- 1. 0x9858effd232b4033e47d90003d41ec34ecaeda94
532
- 2. 0x1234567890abcdef1234567890abcdef12345678
533
- ```
534
-
535
- **JSON Output Example:**
536
-
537
- ```json
538
- {
539
- "domain": "example.com",
540
- "wallets": [
541
- "0x9858effd232b4033e47d90003d41ec34ecaeda94",
542
- "0x1234567890abcdef1234567890abcdef12345678"
543
- ],
544
- "count": 2
545
- }
546
- ```
98
+ - Keep the private key file secure. Only the public key is uploaded on-chain.
99
+ - The signer must be the domain owner (or an authorized account in your workflow).
547
100
 
548
- #### Add Solana Wallet
549
-
550
- Add a Solana wallet address to your domain's authenticated addresses.
551
-
552
- **Requirements:**
101
+ ---
553
102
 
554
- - `PRIVATE_KEY_OR_MNEMONIC` environment variable (domain owner's key)
555
- - `SOLANA_PRIVATE_KEY` environment variable (wallet to add)
103
+ ## Scenario 3: OTMOIC LP Binds Authenticated Addresses
556
104
 
557
- **Solana Private Key Formats:**
105
+ Goal: LP account binds EVM and/or Solana addresses as authenticated addresses under a domain.
558
106
 
559
- - **Base58 format** (from Phantom wallet export): `"5J7W..."`
560
- - **JSON array format**: `"[1,2,3,...]"` (64 bytes)
107
+ ### Bind EVM Address
561
108
 
562
109
  ```bash
110
+ # Domain owner signer
563
111
  export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_DOMAIN_OWNER_KEY"
564
112
 
565
- # Using base58 format (Phantom export)
566
- export SOLANA_PRIVATE_KEY="5J7WpQXHJkD3..."
567
- did-cli wallet solana add example.com
568
-
569
- # Using JSON array format
570
- export SOLANA_PRIVATE_KEY='[174,47,154,...]'
571
- did-cli wallet solana add example.com
113
+ # Wallet private key to be bound
114
+ export EVM_PRIVATE_KEY="0xWALLET_PRIVATE_KEY"
572
115
 
573
- # With JSON output
574
- did-cli wallet solana add example.com --json
116
+ # Add / list / remove
117
+ did-cli wallet evm add olares.com
118
+ did-cli wallet evm list olares.com
119
+ did-cli wallet evm remove olares.com
575
120
  ```
576
121
 
577
- **Output Example:**
578
-
579
- ```
580
- 💼 Adding Solana wallet to domain: example.com
581
-
582
- ✅ Solana wallet added successfully!
583
- Address: 8aKDo9WRy9YyJD5ZjL6nF5zEqG1N4mPxB7sU2wVqT3cH
584
- Transaction: 0x456def...
585
- Gas used: 180000
586
- ```
587
-
588
- #### Remove Solana Wallet
589
-
590
- Remove a Solana wallet address from your domain.
591
-
592
- **Requirements:**
593
-
594
- - `PRIVATE_KEY_OR_MNEMONIC` environment variable (domain owner's key)
595
- - `SOLANA_PRIVATE_KEY` environment variable (wallet to remove)
122
+ ### Bind Solana Address
596
123
 
597
124
  ```bash
125
+ # Domain owner signer
598
126
  export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_DOMAIN_OWNER_KEY"
599
- export SOLANA_PRIVATE_KEY="5J7WpQXHJkD3..."
600
- did-cli wallet solana remove example.com
601
- ```
602
-
603
- #### List Solana Wallets
604
-
605
- List all Solana wallet addresses associated with a domain.
606
-
607
- **No authentication required** (read-only operation)
608
-
609
- ```bash
610
- did-cli wallet solana list example.com
611
127
 
612
- # With JSON output
613
- did-cli wallet solana list example.com --json
614
- ```
615
-
616
- **Output Example:**
128
+ # Solana private key (base58 or JSON array)
129
+ export SOLANA_PRIVATE_KEY="5J7WpQX..."
130
+ # or
131
+ # export SOLANA_PRIVATE_KEY='[174,47,154,...]'
617
132
 
133
+ # Add / list / remove
134
+ did-cli wallet solana add olares.com
135
+ did-cli wallet solana list olares.com
136
+ did-cli wallet solana remove olares.com
618
137
  ```
619
- 📋 Listing Solana wallets for domain: example.com
620
- Found 1 wallet(s):
621
- 1. 8aKDo9WRy9YyJD5ZjL6nF5zEqG1N4mPxB7sU2wVqT3cH
622
- ```
623
-
624
- **Technical Details:**
625
-
626
- 1. **Signature Verification**: Both EVM and Solana wallets use EIP-712 typed data signing for verification
627
- 2. **Ed25519 Signatures**: Solana uses Ed25519 signatures for authentication
628
- 3. **Timestamp Validation**: Signatures must be generated within 1 hour of the current time
629
- 4. **Storage**: Wallet addresses are stored in the RootTagger2 contract
630
- 5. **Backward Compatibility**: `list` command also fetches addresses from legacy RootResolver contract
631
-
632
- ### Admin Commands
633
-
634
- Manage contract-level administrative functions including ownership and operator management.
635
138
 
636
- #### Get Contract Owner
139
+ Practical notes:
637
140
 
638
- Get the current owner address of the DID contract.
639
-
640
- ```bash
641
- did-cli admin get-owner [options]
642
-
643
- # Examples
644
- did-cli admin get-owner
645
- did-cli admin get-owner --json
646
- did-cli admin get-owner --network sepolia
647
- ```
648
-
649
- **Output Example:**
650
-
651
- ```
652
- 👤 Contract Owner: 0x1234567890abcdef...
653
- ```
654
-
655
- #### Get Total Supply
656
-
657
- Get the total number of registered domains.
658
-
659
- ```bash
660
- did-cli admin get-totalsupply [options]
661
-
662
- # Examples
663
- did-cli admin get-totalsupply
664
- did-cli admin get-totalsupply --json
665
- ```
666
-
667
- **Output Example:**
668
-
669
- ```
670
- 📊 Total Domains: 12345
671
- ```
672
-
673
- #### Get Operator Address
674
-
675
- Get the current operator address (super admin).
676
-
677
- ```bash
678
- did-cli admin get-operator [options]
679
-
680
- # Examples
681
- did-cli admin get-operator
682
- did-cli admin get-operator --json
683
- did-cli admin get-operator --network sepolia
684
- ```
685
-
686
- **Output Example:**
687
-
688
- ```
689
- 👔 Operator: 0x5678901234abcdef...
690
- ```
691
-
692
- #### Set Operator Address
693
-
694
- Set the operator address. Only the contract owner can call this.
695
-
696
- ```bash
697
- did-cli admin set-operator <address>
698
-
699
- # Examples
700
- export PRIVATE_KEY_OR_MNEMONIC=0x1234...
701
- did-cli admin set-operator 0x5678...
702
- did-cli admin set-operator 0x5678... --json
703
- ```
704
-
705
- **Output Example:**
706
-
707
- ```
708
- ✅ Operator set to 0x5678...
709
- 📝 Transaction: 0xabc123...
710
- ⛽ Gas used: 45000
711
- ```
712
-
713
- #### Transfer Contract Ownership
714
-
715
- Initiate transfer of contract ownership to a new address. The new owner must call `accept-ownership` to complete the transfer.
716
-
717
- ```bash
718
- did-cli admin transfer-ownership <new-owner-address>
719
-
720
- # Examples
721
- export PRIVATE_KEY_OR_MNEMONIC=0x1234...
722
- did-cli admin transfer-ownership 0x9999...
723
- did-cli admin transfer-ownership 0x9999... --json
724
- ```
725
-
726
- **Output Example:**
727
-
728
- ```
729
- ✅ Ownership transfer initiated to 0x9999...
730
- 📝 Transaction: 0xdef456...
731
- ⛽ Gas used: 50000
732
-
733
- ⚠️ Note: The new owner must call "admin accept-ownership" to complete the transfer
734
- ```
735
-
736
- **Important Notes:**
737
-
738
- - Only the current contract owner can initiate ownership transfer
739
- - This is a two-step process for safety:
740
- 1. Current owner calls `transfer-ownership`
741
- 2. New owner calls `accept-ownership`
742
- - The pending owner can be queried from the contract
743
-
744
- #### Accept Ownership Transfer
745
-
746
- Accept a pending ownership transfer. Must be called by the pending owner.
747
-
748
- ```bash
749
- did-cli admin accept-ownership
750
-
751
- # Examples
752
- export PRIVATE_KEY_OR_MNEMONIC=0x9999... # New owner's private key
753
- did-cli admin accept-ownership
754
- did-cli admin accept-ownership --json
755
- ```
756
-
757
- **Output Example:**
758
-
759
- ```
760
- ✅ Ownership transfer accepted successfully
761
- 📝 Transaction: 0xghi789...
762
- ⛽ Gas used: 48000
763
- ```
764
-
765
- **Important Notes:**
766
-
767
- - Only the pending owner (set by `transfer-ownership`) can accept
768
- - After acceptance, you become the new contract owner
769
- - This completes the ownership transfer process
770
-
771
- ### Utility Commands
772
-
773
- #### Convert PEM to DER
774
-
775
- ```bash
776
- did-cli convert pem-to-der <pem-file> [options]
777
-
778
- # Examples
779
- did-cli convert pem-to-der ./public-key.pem
780
- did-cli convert pem-to-der ./public-key.pem --json
781
- did-cli convert pem-to-der ./public-key.pem --output ./key.der
782
- ```
783
-
784
- #### Convert DER to PEM
785
-
786
- ```bash
787
- did-cli convert der-to-pem <der-hex> [options]
788
-
789
- # Examples
790
- did-cli convert der-to-pem 0x3082010a...
791
- did-cli convert der-to-pem 0x3082010a... --json
792
- did-cli convert der-to-pem 0x3082010a... --output ./key.pem
793
- ```
794
-
795
- #### Convert IPv4 to Bytes4
796
-
797
- ```bash
798
- did-cli convert ip-to-bytes <ipv4-address> [options]
799
-
800
- # Examples
801
- did-cli convert ip-to-bytes 192.168.1.1
802
- did-cli convert ip-to-bytes 192.168.1.1 --json
803
- ```
804
-
805
- #### Convert Bytes4 to IPv4
806
-
807
- ```bash
808
- did-cli convert bytes-to-ip <bytes4-hex> [options]
809
-
810
- # Examples
811
- did-cli convert bytes-to-ip 0xc0a80101
812
- did-cli convert bytes-to-ip 0xc0a80101 --json
813
- ```
141
+ - `PRIVATE_KEY_OR_MNEMONIC` is the domain authorization key.
142
+ - `EVM_PRIVATE_KEY` or `SOLANA_PRIVATE_KEY` is the wallet being bound.
143
+ - If add fails because the address already exists, check with `wallet ... list` first.
814
144
 
815
145
  ---
816
146
 
817
- ## Tag Management Commands
818
-
819
- Tags are typed key-value pairs that can be attached to domains for storing structured metadata on-chain. The CLI provides simple commands for basic tag operations with common types.
820
-
821
- > **📖 For Advanced Usage**: For complex types (tuples/structs), array element operations, and detailed API documentation, see the [Tag System Documentation](./docs/TAG_SYSTEM.md) and check the [examples](./examples/) directory.
147
+ ## Scenario 4: Org Admin Creates Subdomain and Manages Subdomain Tags
822
148
 
823
- ### Define Tag Type
149
+ Goal: org admin creates a subdomain, defines tag type on the org domain, sets self as tagger, then writes tag values for the subdomain object.
824
150
 
825
- Define a new tag with a specific type. Tags must be defined before they can be used.
151
+ ### Step A: Org Admin Creates Subdomain
826
152
 
827
153
  ```bash
828
- did-cli tag define <domain> <tag-name> <type>
829
- ```
830
-
831
- **Supported Types:**
832
-
833
- - Simple types: `string`, `uint8`, `uint256`, `int8`, `int256`, `bool`, `address`, `bytes`, `bytes32`
834
- - Array types: `"string[]"`, `"uint8[]"`, `"address[]"`, etc. (must be quoted!)
835
-
836
- **Requirements:** `PRIVATE_KEY_OR_MNEMONIC` environment variable
837
-
838
- **Examples:**
839
-
840
- ```bash
841
- export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_PRIVATE_KEY"
842
-
843
- # Define simple types
844
- did-cli tag define example.com email string
845
- did-cli tag define example.com age uint8
846
- did-cli tag define example.com verified bool
847
- did-cli tag define example.com owner address
848
-
849
- # Define array types (MUST be quoted!)
850
- did-cli tag define example.com wallets "address[]"
851
- did-cli tag define example.com socialLinks "string[]"
852
-
853
- # With JSON output
854
- did-cli tag define example.com followers uint256 --json
855
- ```
856
-
857
- **Output Example:**
858
-
859
- ```
860
- 📝 Defining tag "email" for domain: example.com
861
- Type: string
862
-
863
- ✅ Tag "email" defined successfully
864
- Transaction: 0x123abc...
865
- Gas used: 150000
866
- ```
867
-
868
- ### Set Tagger
869
-
870
- Set the authorized address (tagger) that can modify a tag's value. Only the domain owner can set the tagger.
871
-
872
- ```bash
873
- did-cli tag set-tagger <domain> <tag-name> <tagger-address>
874
- ```
875
-
876
- **Requirements:** `PRIVATE_KEY_OR_MNEMONIC` environment variable
877
-
878
- **Examples:**
879
-
880
- ```bash
881
- export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_PRIVATE_KEY"
882
-
883
- # Set tagger to a specific address
884
- did-cli tag set-tagger example.com email 0x1234567890abcdef...
885
-
886
- # Set tagger to yourself
887
- SIGNER_ADDRESS=$(did-cli crypto address)
888
- did-cli tag set-tagger example.com email $SIGNER_ADDRESS
889
- ```
890
-
891
- **Output Example:**
892
-
893
- ```
894
- 🔐 Setting tagger for tag "email" in domain: example.com
895
- Tagger address: 0x1234567890abcdef...
896
-
897
- ✅ Tagger set successfully
898
- Transaction: 0x456def...
899
- ```
900
-
901
- ### Set Tag Value
902
-
903
- Set or update a tag's value. You must be the designated tagger for this tag.
904
-
905
- ```bash
906
- did-cli tag set <domain> <tag-name> <value>
907
- ```
908
-
909
- **Value Formats:**
910
-
911
- - **Strings**: Direct input (`user@example.com`) or JSON string
912
- - **Numbers**: Direct input (`30`, `1000`)
913
- - **Booleans**: `true` or `false`
914
- - **Arrays**: JSON format, must be quoted (`'["item1","item2"]'`)
915
-
916
- **Requirements:** `PRIVATE_KEY_OR_MNEMONIC` environment variable
917
-
918
- **Examples:**
919
-
920
- ```bash
921
- export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_PRIVATE_KEY"
922
-
923
- # Set string value
924
- did-cli tag set example.com email "user@example.com"
925
- did-cli tag set example.com bio "Web3 developer and blockchain enthusiast"
926
-
927
- # Set number value
928
- did-cli tag set example.com age 30
929
- did-cli tag set example.com followers 1350
930
-
931
- # Set boolean value
932
- did-cli tag set example.com verified true
933
- did-cli tag set example.com premium false
934
-
935
- # Set array value (use JSON, must be quoted!)
936
- did-cli tag set example.com socialLinks '["https://twitter.com/alice","https://github.com/alice"]'
937
- did-cli tag set example.com wallets '["0x1111111111111111111111111111111111111111","0x2222222222222222222222222222222222222222"]'
938
-
939
- # With JSON output
940
- did-cli tag set example.com email "user@example.com" --json
941
- ```
942
-
943
- **Output Example:**
944
-
945
- ```
946
- 📝 Setting tag "email" for domain: example.com
947
- Value: user@example.com
948
-
949
- ✅ Tag "email" set successfully
950
- Transaction: 0x789ghi...
951
- Gas used: 120000
952
- ```
953
-
954
- ### Get Tag Value
955
-
956
- Read a tag's current value. This is a read-only operation and doesn't require authentication.
154
+ # Parent domain owner key
155
+ export PRIVATE_KEY_OR_MNEMONIC="0xPARENT_DOMAIN_OWNER_KEY"
957
156
 
958
- ```bash
959
- did-cli tag get <domain> <tag-name>
960
- ```
961
-
962
- **Requirements:** None (read-only)
963
-
964
- **Examples:**
965
-
966
- ```bash
967
- # Get any tag value
968
- did-cli tag get example.com email
969
- did-cli tag get example.com age
970
- did-cli tag get example.com socialLinks
971
-
972
- # With JSON output
973
- did-cli tag get example.com email --json
974
- ```
975
-
976
- **Output Examples:**
977
-
978
- ```
979
- 📖 Getting tag "email" for domain: example.com
980
-
981
- ✅ Tag value:
982
- user@example.com
983
- ```
984
-
985
- ```
986
- 📖 Getting tag "socialLinks" for domain: example.com
987
-
988
- ✅ Tag value:
989
- ["https://twitter.com/alice","https://github.com/alice"]
990
- ```
991
-
992
- ### Remove Tag Value
993
-
994
- Remove a tag's value while keeping its definition. The tag can be set again later.
995
-
996
- ```bash
997
- did-cli tag remove <domain> <tag-name>
998
- ```
999
-
1000
- **Requirements:** `PRIVATE_KEY_OR_MNEMONIC` environment variable
1001
-
1002
- **Examples:**
1003
-
1004
- ```bash
1005
- export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_PRIVATE_KEY"
1006
-
1007
- # Remove tag value
1008
- did-cli tag remove example.com email
1009
-
1010
- # With JSON output
1011
- did-cli tag remove example.com email --json
1012
- ```
1013
-
1014
- **Output Example:**
1015
-
1016
- ```
1017
- 🗑️ Removing tag "email" for domain: example.com
1018
-
1019
- ✅ Tag "email" value removed successfully
1020
- Transaction: 0xabc123...
1021
- ```
1022
-
1023
- **Note:** This removes the _value_ only, not the tag definition. The tag type remains defined and can be set again.
1024
-
1025
- ### List All Tags
1026
-
1027
- List all tags and their current values for a domain.
1028
-
1029
- ```bash
1030
- did-cli tag list <domain>
157
+ # Register child under parent.com => child.parent.com
158
+ did-cli subdomain register parent.com child
1031
159
  ```
1032
160
 
1033
- **Requirements:** None (read-only)
1034
-
1035
- **Examples:**
161
+ ### Step B: Org Admin Defines Tag Type on Parent (Org) Domain
1036
162
 
1037
163
  ```bash
1038
- # List all tags
1039
- did-cli tag list example.com
1040
-
1041
- # With JSON output
1042
- did-cli tag list example.com --json
1043
- ```
164
+ # Still using org admin key
165
+ export PRIVATE_KEY_OR_MNEMONIC="0xPARENT_DOMAIN_OWNER_KEY"
1044
166
 
1045
- **Output Example:**
1046
-
1047
- ```
1048
- 📋 Listing all tags for domain: example.com
1049
-
1050
- ✅ Found 7 tags:
1051
-
1052
- Tag: "email"
1053
- Value: user@example.com
1054
- Tag: "age"
1055
- Value: 30
1056
- Tag: "verified"
1057
- Value: true
1058
- Tag: "bio"
1059
- Value: Web3 developer and blockchain enthusiast
1060
- Tag: "followers"
1061
- Value: 1350
1062
- Tag: "socialLinks"
1063
- Value: ["https://twitter.com/alice","https://github.com/alice"]
1064
- Tag: "wallets"
1065
- Value: ["0x1111111111111111111111111111111111111111"]
167
+ # Define tag type on parent/org domain
168
+ did-cli tag define parent.com profile string
1066
169
  ```
1067
170
 
1068
- ### List Defined Tag Types
1069
-
1070
- List all defined tag types for a domain, including those without values.
171
+ ### Step C: Org Admin Sets Self as Tagger
1071
172
 
1072
173
  ```bash
1073
- did-cli tag list-defined <domain>
174
+ export PRIVATE_KEY_OR_MNEMONIC="0xPARENT_DOMAIN_OWNER_KEY"
175
+ did-cli tag set-tagger parent.com profile 0xORG_ADMIN_ADDRESS
1074
176
  ```
1075
177
 
1076
- **Requirements:** None (read-only)
1077
-
1078
- **Examples:**
178
+ Tip: if needed, you can get admin address first:
1079
179
 
1080
180
  ```bash
1081
- # List defined tag types
1082
- did-cli tag list-defined example.com
1083
-
1084
- # With JSON output
1085
- did-cli tag list-defined example.com --json
1086
- ```
1087
-
1088
- **Output Example:**
1089
-
1090
- ```
1091
- 📋 Listing defined tag types for domain: example.com
1092
-
1093
- ✅ Found 9 defined tag types:
1094
-
1095
- - email
1096
- - age
1097
- - verified
1098
- - bio
1099
- - followers
1100
- - premium
1101
- - socialLinks
1102
- - wallets
1103
- - userInfo
181
+ export PRIVATE_KEY_OR_MNEMONIC="0xPARENT_DOMAIN_OWNER_KEY"
182
+ did-cli crypto address
1104
183
  ```
1105
184
 
1106
- ### Get Tagger
1107
-
1108
- Get the current tagger address for a tag.
185
+ ### Step D: Org Admin Sets Tag Value for Subdomain Object
1109
186
 
1110
187
  ```bash
1111
- did-cli tag get-tagger <domain> <tag-name>
188
+ export PRIVATE_KEY_OR_MNEMONIC="0xPARENT_DOMAIN_OWNER_KEY"
189
+ did-cli tag set child.parent.com profile "builder of team alpha" --from parent.com
1112
190
  ```
1113
191
 
1114
- **Requirements:** None (read-only)
1115
-
1116
- **Examples:**
192
+ Verify result:
1117
193
 
1118
194
  ```bash
1119
- # Get tagger address
1120
- did-cli tag get-tagger example.com email
1121
-
1122
- # With JSON output
1123
- did-cli tag get-tagger example.com email --json
1124
- ```
1125
-
1126
- **Output Example:**
1127
-
195
+ did-cli tag get child.parent.com profile --from parent.com
196
+ did-cli tag list child.parent.com --from parent.com
1128
197
  ```
1129
- 🔍 Getting tagger for tag "email" in domain: example.com
1130
198
 
1131
- Tagger address: 0x1234567890abcdef...
1132
- ```
199
+ Practical notes:
1133
200
 
1134
- ### Complete Tag Workflow Example
201
+ - Define tag type first, then set tagger, then set value.
202
+ - In this workflow, tag type and tagger are managed on the parent/org domain, while the value is written to the target subdomain object.
203
+ - Use `--from` whenever tag type is defined on a different domain than the target object.
204
+ - `tag list-defined` supports root query when domain is omitted:
1135
205
 
1136
206
  ```bash
1137
- # 1. Set authentication
1138
- export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_PRIVATE_KEY"
1139
-
1140
- # 2. Define tag types
1141
- did-cli tag define example.com bio string
1142
- did-cli tag define example.com followers uint256
1143
- did-cli tag define example.com premium bool
1144
- did-cli tag define example.com socialLinks "string[]"
1145
-
1146
- # 3. Get your address and set as tagger
1147
- SIGNER_ADDRESS=$(did-cli crypto address)
1148
- did-cli tag set-tagger example.com bio $SIGNER_ADDRESS
1149
- did-cli tag set-tagger example.com followers $SIGNER_ADDRESS
1150
- did-cli tag set-tagger example.com premium $SIGNER_ADDRESS
1151
- did-cli tag set-tagger example.com socialLinks $SIGNER_ADDRESS
1152
-
1153
- # 4. Set tag values
1154
- did-cli tag set example.com bio "Web3 developer and blockchain enthusiast"
1155
- did-cli tag set example.com followers 1350
1156
- did-cli tag set example.com premium true
1157
- did-cli tag set example.com socialLinks '["https://twitter.com/alice","https://github.com/alice"]'
1158
-
1159
- # 5. Read values (no auth required)
1160
- did-cli tag get example.com bio
1161
- did-cli tag list example.com
1162
-
1163
- # 6. Update a value
1164
- did-cli tag set example.com followers 1500
1165
-
1166
- # 7. Remove a value
1167
- did-cli tag remove example.com premium
207
+ did-cli tag list-defined
1168
208
  ```
1169
209
 
1170
- ### Important Notes
1171
-
1172
- 1. **Array Types Must Be Quoted**: When using array types like `address[]` or `string[]`, you must quote them to prevent shell interpretation:
1173
-
1174
- ```bash
1175
- # ✅ Correct
1176
- did-cli tag define example.com wallets "address[]"
1177
-
1178
- # ❌ Wrong - shell will interpret []
1179
- did-cli tag define example.com wallets address[]
1180
- ```
1181
-
1182
- 2. **Array Values Must Be JSON**: When setting array values, use valid JSON and quote the entire value:
1183
-
1184
- ```bash
1185
- # ✅ Correct
1186
- did-cli tag set example.com links '["https://twitter.com","https://github.com"]'
1187
-
1188
- # ❌ Wrong
1189
- did-cli tag set example.com links https://twitter.com,https://github.com
1190
- ```
1191
-
1192
- 3. **Set Tagger Before Setting Values**: You must set a tagger after defining a tag and before you can set its value:
1193
-
1194
- ```bash
1195
- did-cli tag define example.com email string
1196
- did-cli tag set-tagger example.com email $YOUR_ADDRESS # Required!
1197
- did-cli tag set example.com email "user@example.com"
1198
- ```
1199
-
1200
- 4. **CLI Limitations**: The CLI only supports simple types and arrays. For complex tuple types and advanced operations:
1201
-
1202
- - Use the SDK directly (see [TAG.md](./TAG.md))
1203
- - Check examples in [`examples/tag-management.ts`](./examples/tag-management.ts)
1204
-
1205
- 5. **Tags Are Immutable After Definition**: You cannot change a tag's type once defined. You can only set/update/remove values.
1206
-
1207
210
  ---
1208
211
 
1209
- ## Global Options
1210
-
1211
- | Option | Description | Default |
1212
- | --- | --- | --- |
1213
- | `-n, --network <network>` | Network to use (sepolia\|mainnet) | mainnet |
1214
- | `--rpc <url>` | Custom RPC endpoint URL | - |
1215
- | `--contract-did <address>` | Custom DID contract address | - |
1216
- | `--contract-resolver <address>` | Custom RootResolver contract address | - |
1217
- | `--contract-abi <address>` | Custom ABIType contract address | - |
1218
- | `--contract-resolver2 <address>` | Custom RootResolver2 contract address | - |
1219
- | `--support-svc-url <url>` | Custom support service URL | - |
1220
- | `-o, --output <file>` | Output file path | - |
1221
- | `--key-length <bits>` | RSA key length in bits | 2048 |
1222
- | `-w, --words <count>` | Mnemonic word count (12\|15\|18\|21\|24) | 12 |
1223
- | `-j, --json` | Output in JSON format | false |
1224
- | `-v, --verbose` | Enable verbose debug output | false |
1225
- | `--debug` | Enable debug output | false |
1226
- | `--debug-level <level>` | Set debug level (debug\|info\|warn\|error) | info |
1227
- | `-h, --help` | Show help message | - |
1228
- | `-V, --version` | Show version number | - |
1229
-
1230
- ## Environment Variables
1231
-
1232
- | Variable | Description |
1233
- | --- | --- |
1234
- | `PRIVATE_KEY_OR_MNEMONIC` | Private key (0x...) or BIP39 mnemonic phrase for signing transactions (required for write operations like transfer, set RSA key, set IP, wallet management, etc.) |
1235
- | `SUBDOMAIN_OWNER_MNEMONIC` | BIP39 mnemonic phrase for generating subdomain owner identity (used in subdomain registration) |
1236
- | `TO_MNEMONIC` | BIP39 mnemonic phrase for generating new owner identity (used in domain transfer) |
1237
- | `MNEMONIC` | BIP39 mnemonic phrase for crypto utility commands (used in crypto address, did, privatekey, derive) |
1238
- | `EVM_PRIVATE_KEY` | EVM wallet private key (0x...) for wallet management operations (required for `wallet evm add/remove` commands) |
1239
- | `SOLANA_PRIVATE_KEY` | Solana wallet private key for wallet management operations (required for `wallet solana add/remove` commands). Supports base58 or JSON array format |
1240
-
1241
- **Security Note:** Using environment variables for private keys or mnemonics prevents them from being stored in shell history, which is more secure than passing them as command-line arguments.
1242
-
1243
- **Format Examples:**
1244
-
1245
- - Private key: `export PRIVATE_KEY_OR_MNEMONIC=0x1234567890abcdef...`
1246
- - Mnemonic: `export PRIVATE_KEY_OR_MNEMONIC="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"`
1247
-
1248
- > **⚠️ Important: Always use quotes for mnemonic phrases!**
1249
- >
1250
- > Without quotes, the shell will only capture the first word:
1251
- >
1252
- > ```bash
1253
- > # ❌ WRONG - Only captures "advice"
1254
- > export PRIVATE_KEY_OR_MNEMONIC=advice wrestle recycle yellow light avoid shell mutual ketchup obscure game corn
1255
- >
1256
- > # ✅ CORRECT - Captures the entire phrase
1257
- > export PRIVATE_KEY_OR_MNEMONIC="advice wrestle recycle yellow light avoid shell mutual ketchup obscure game corn"
1258
- > ```
1259
-
1260
- ## Network Configuration
1261
-
1262
- ### Configuration File
1263
-
1264
- All network settings are stored in `config.json` in the package directory. You can modify settings using CLI commands or by directly editing the file.
1265
-
1266
- **Priority:** Command-line args > config file values
1267
-
1268
- ### Configuration Commands
212
+ ## Common Pitfalls in Real Workflows
1269
213
 
1270
- ```bash
1271
- # Show configuration
1272
- did-cli config show [--network mainnet|sepolia]
1273
-
1274
- # List all networks
1275
- did-cli config list
1276
-
1277
- # Set configuration value (creates network if it doesn't exist)
1278
- did-cli config set <key> <value> [--network <network>]
1279
- # Keys: rpc, contractDid, contractRootResolver, contractAbiType,
1280
- # contractRootResolver2, supportSvcUrl
1281
- # Default network: mainnet
1282
- ```
1283
-
1284
- **Examples:**
214
+ - Mnemonic must be quoted:
1285
215
 
1286
216
  ```bash
1287
- # View mainnet config
1288
- did-cli config show --network mainnet
1289
-
1290
- # Update mainnet RPC (default network)
1291
- did-cli config set rpc https://eth.llamarpc.com
1292
-
1293
- # Update sepolia contract
1294
- did-cli config set contractDid 0x1234... --network sepolia
1295
-
1296
- # Add new network
1297
- did-cli config set rpc https://my-rpc.com --network custom_net
1298
- did-cli config set contractDid 0x5678... --network custom_net
1299
-
1300
- # List all networks
1301
- did-cli config list
217
+ export PRIVATE_KEY_OR_MNEMONIC="advice wrestle recycle ..."
1302
218
  ```
1303
219
 
1304
- ### Default Networks
1305
-
1306
- #### Mainnet (Default)
1307
-
1308
- - RPC: `https://optimism-rpc.publicnode.com`
1309
- - DID Contract: `0x5DA4Fa8E567d86e52Ef8Da860de1be8f54cae97D`
1310
- - RootResolver: `0x0223be5559961f9D393b28EFD1dBEdcB2dD67523`
1311
- - ABI Type: `0x9ae3F16bD99294Af1784beB1a0A5C84bf2636365`
1312
- - RootResolver2: `0x7e7961aB771cA942CE4DB6e79579e016a33Dc95B`
1313
- - Support Service: `https://api.olares.com/did/support`
1314
-
1315
- #### Sepolia Testnet
1316
-
1317
- - RPC: `https://sepolia.optimism.io`
1318
- - DID Contract: `0xe2D7c3a9013960E04d4E9F5F9B63fff37eEd97A8`
1319
- - RootResolver: `0xcB045D9133A4F5ffCe2C98b2C47e951e8c9A0655`
1320
- - ABI Type: `0x7386fCBae6Ad4CCE1499d9153D99bc950B589718`
1321
- - RootResolver2: `0xcbC02aa08c77a374eC0D5A0403E108b7573d96e8`
1322
- - Support Service: `https://api-test.olares.com/did/support`
1323
-
1324
- ## Output Formats
1325
-
1326
- ### Human-Readable (Default)
1327
-
1328
- ```bash
1329
- $ did-cli info example.olares.com
1330
-
1331
- 📋 Domain Metadata:
1332
- Name: example.olares.com
1333
- DID: did:key:z6Mkm...
1334
- Token ID: 1234567890123456789012345678901234567890
1335
- Note: Individual:TerminusUser
1336
- Allow Subdomain: true
1337
- ```
1338
-
1339
- ### JSON Format
1340
-
1341
- ```bash
1342
- $ did-cli info example.olares.com --json
1343
-
1344
- {
1345
- "name": "example.olares.com",
1346
- "did": "did:key:z6Mkm...",
1347
- "id": "1234567890123456789012345678901234567890",
1348
- "note": "Individual:TerminusUser",
1349
- "allowSubdomain": true
1350
- }
1351
- ```
1352
-
1353
- ## Examples
1354
-
1355
- ### Complete Workflow: Register and Configure a Domain
1356
-
1357
- ```bash
1358
- # 1. Set your private key or mnemonic (do this once per session)
1359
- export PRIVATE_KEY_OR_MNEMONIC=0x1234567890abcdef...
1360
- # Or use mnemonic
1361
- export PRIVATE_KEY_OR_MNEMONIC="your twelve word mnemonic phrase here"
1362
-
1363
- # 2. Check ownership
1364
- did-cli is-owner example.olares.com
1365
-
1366
- # 3. Generate RSA key pair
1367
- did-cli rsa generate --output ./example-key.pem --key-length 2048
1368
-
1369
- # 4. Set RSA public key
1370
- did-cli rsa set example.olares.com ./example-key.pem
1371
-
1372
- # 5. Set IP address
1373
- did-cli ip set example.olares.com 192.168.1.100
1374
-
1375
- # 6. Verify configuration
1376
- did-cli info example.olares.com
1377
- did-cli rsa get example.olares.com
1378
- did-cli ip get example.olares.com
1379
- ```
1380
-
1381
- ### Persisting Private Key Across Sessions
220
+ - Array type must be quoted in shell:
1382
221
 
1383
222
  ```bash
1384
- # Add to your ~/.bashrc or ~/.zshrc for persistence
1385
- echo 'export PRIVATE_KEY_OR_MNEMONIC=0x1234567890abcdef...' >> ~/.bashrc
1386
- source ~/.bashrc
1387
-
1388
- # Or use a .env file (recommended for development)
1389
- echo 'PRIVATE_KEY_OR_MNEMONIC=0x1234567890abcdef...' > .env
1390
- # Then load it before using CLI
1391
- export $(cat .env | xargs)
1392
-
1393
- # Now you can use commands without setting PRIVATE_KEY_OR_MNEMONIC each time
1394
- did-cli rsa set example.olares.com ./key.pem
1395
- did-cli ip set example.olares.com 192.168.1.100
1396
- did-cli operator set 0x5678...
223
+ did-cli tag define olares.com wallets "address[]"
1397
224
  ```
1398
225
 
1399
- ### Batch Operations with JSON Output
226
+ - Array value should be valid JSON string:
1400
227
 
1401
228
  ```bash
1402
- # Query multiple domains
1403
- for domain in example1.olares.com example2.olares.com; do
1404
- did-cli info $domain --json >> domains.json
1405
- done
1406
-
1407
- # Process JSON output with jq
1408
- did-cli info example.olares.com --json | jq '.owner'
229
+ did-cli tag set olares.com links '["https://x.com","https://github.com"]'
1409
230
  ```
1410
231
 
1411
- ## Error Handling
1412
-
1413
- The CLI provides clear error messages for common issues:
232
+ - Cross-domain tag read/write/list must specify `--from`:
1414
233
 
1415
234
  ```bash
1416
- # Missing required argument
1417
- $ did-cli info
1418
- Error: Domain argument is required
1419
- Usage: did-cli info <domain>
1420
-
1421
- # Invalid IP address
1422
- $ did-cli ip set example.olares.com invalid-ip
1423
- ❌ Error: Invalid IPv4 address format
1424
-
1425
- # Missing private key or mnemonic
1426
- $ did-cli is-owner example.olares.com
1427
- ❌ Error: Private key or mnemonic is required for this operation
1428
- Please set PRIVATE_KEY_OR_MNEMONIC environment variable
1429
- Example: export PRIVATE_KEY_OR_MNEMONIC=0xYOUR_PRIVATE_KEY
1430
- Or: export PRIVATE_KEY_OR_MNEMONIC="your twelve words..."
235
+ did-cli tag set child.parent.com profile "builder" --from parent.com
236
+ did-cli tag get child.parent.com profile --from parent.com
237
+ did-cli tag list child.parent.com --from parent.com
1431
238
  ```
1432
239
 
1433
- ## Development
1434
-
1435
- ### Run from Source
240
+ - For tags defined on root (`""`), use `--from root`:
1436
241
 
1437
242
  ```bash
1438
- # Clone repository
1439
- git clone https://github.com/olares/did-system.git
1440
- cd did-system/packages/olaresid
1441
-
1442
- # Install dependencies
1443
- npm install
1444
-
1445
- # Run CLI
1446
- npx ts-node src/cli.ts <command>
243
+ did-cli tag get child.parent.com latestDID --from root
1447
244
  ```
1448
245
 
1449
- ### Debug Mode
246
+ - Use `--network sepolia` for test runs before mainnet writes.
1450
247
 
1451
- ```bash
1452
- # Enable verbose output
1453
- did-cli info example.olares.com --verbose
1454
-
1455
- # Enable debug output with level
1456
- did-cli info example.olares.com --debug --debug-level debug
1457
- ```
248
+ ---
1458
249
 
1459
- ## License
250
+ ## Quick Pointers
1460
251
 
1461
- See the main repository LICENSE file.
252
+ - Full tag concepts and SDK usage: [TAG.md](./TAG.md)
253
+ - Project overview and SDK quick start: [README.md](./README.md)
254
+ - Full command list: run `did-cli --help`