polkadot-cli 1.12.0 → 1.14.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 (3) hide show
  1. package/README.md +271 -56
  2. package/dist/cli.mjs +1770 -353
  3. package/package.json +8 -10
package/README.md CHANGED
@@ -15,33 +15,37 @@ Ships with Polkadot and all system parachains preconfigured with multiple fallba
15
15
  - ✅ Exposes all on-chain metadata documentation
16
16
  - ✅ Encode, dry-run, and submit extrinsics
17
17
  - ✅ Support for custom signed extensions
18
- - ✅ Built with agent use in mind — pipe-safe JSON output (`--output json`)
18
+ - ✅ Built with agent use in mind — structured JSON output on every command (`--json`)
19
19
  - ✅ Fuzzy matching with typo suggestions
20
20
  - ✅ Account management — BIP39 mnemonics, derivation paths, env-backed secrets, watch-only, dev accounts
21
21
  - ✅ Named address resolution across all commands
22
22
  - ✅ Runtime API calls — `dot apis.Core.version`
23
+ - ✅ Chain topology — relay/parachain hierarchy with tree display and auto-detection
23
24
  - ✅ Batteries included — all system parachains and testnets already setup to be used
24
25
  - ✅ File-based commands — run any command from a YAML/JSON file with variable substitution
25
26
  - ✅ Parachain sovereign accounts — derive child and sibling addresses from a parachain ID
26
27
  - ✅ Message signing — sign arbitrary bytes with account keypairs for use as `MultiSignature` arguments
28
+ - ✅ Unsigned/authorized transactions — submit governance-authorized calls without a signer (`--unsigned`)
29
+ - ✅ Non-native fee payment — pay tx fees in any asset the chain accepts via `--asset` (asset-hub-style chains)
27
30
  - ✅ Bandersnatch member keys — derive Ring VRF member keys from mnemonics for on-chain member sets
31
+ - ✅ Export/import — portable chain and account configuration for backup, sharing, and CI bootstrapping
28
32
 
29
33
  ### Preconfigured chains
30
34
 
31
- | Network | Chain | Light client |
32
- |---------|-------|:---:|
33
- | Polkadot | `polkadot` (relay, default) | yes |
34
- | | `polkadot-asset-hub` | yes |
35
- | | `polkadot-bridge-hub` | yes |
36
- | | `polkadot-collectives` | yes |
37
- | | `polkadot-coretime` | yes |
38
- | | `polkadot-people` | yes |
39
- | Paseo (testnet) | `paseo` (relay) | yes |
40
- | | `paseo-asset-hub` | yes |
41
- | | `paseo-bridge-hub` | — |
42
- | | `paseo-collectives` | — |
43
- | | `paseo-coretime` | yes |
44
- | | `paseo-people` | yes |
35
+ | Network | Chain |
36
+ |---------|-------|
37
+ | Polkadot | `polkadot` (relay) |
38
+ | | `polkadot-asset-hub` |
39
+ | | `polkadot-bridge-hub` |
40
+ | | `polkadot-collectives` |
41
+ | | `polkadot-coretime` |
42
+ | | `polkadot-people` |
43
+ | Paseo (testnet) | `paseo` (relay) |
44
+ | | `paseo-asset-hub` |
45
+ | | `paseo-bridge-hub` |
46
+ | | `paseo-collectives` |
47
+ | | `paseo-coretime` |
48
+ | | `paseo-people` |
45
49
 
46
50
  Each chain ships with multiple RPC endpoints from decentralized infrastructure providers (IBP, Dotters, Dwellir, and others). The CLI automatically falls back to the next endpoint if the primary is unreachable.
47
51
 
@@ -68,24 +72,97 @@ dot chain add kusama --rpc wss://kusama-rpc.polkadot.io
68
72
  # Add a chain with fallback RPCs (repeat --rpc for each endpoint)
69
73
  dot chain add kusama --rpc wss://kusama-rpc.polkadot.io --rpc wss://kusama-rpc.dwellir.com
70
74
 
71
- # Add a chain via light client
72
- dot chain add westend --light-client
75
+ # Add a parachain under a relay (auto-detects parachain ID)
76
+ dot chain add local-asset-hub --rpc ws://localhost:9945 --relay local-relay
73
77
 
74
- # List configured chains
78
+ # Add a parachain with explicit parachain ID
79
+ dot chain add my-para --rpc wss://rpc.example.com --relay polkadot --parachain-id 2000
80
+
81
+ # List configured chains (shows relay/parachain hierarchy)
75
82
  dot chain list
76
83
 
77
84
  # Re-fetch metadata after a runtime upgrade
78
- dot chain update # updates default chain
79
85
  dot chain update kusama # updates a specific chain
80
86
  dot chain update --all # updates all configured chains in parallel
81
87
 
82
- # Set default chain
83
- dot chain default kusama
84
-
85
88
  # Remove a chain
86
89
  dot chain remove westend
87
90
  ```
88
91
 
92
+ #### Chain topology
93
+
94
+ `dot chain list` displays chains as a tree, grouping parachains under their parent relay:
95
+
96
+ ```
97
+ Configured Chains
98
+
99
+ polkadot wss://polkadot.ibp.network
100
+ ├─ polkadot-asset-hub [1000] wss://...
101
+ ├─ polkadot-bridge-hub [1002] wss://...
102
+ ├─ polkadot-collectives [1001] wss://...
103
+ ├─ polkadot-coretime [1005] wss://...
104
+ └─ polkadot-people [1004] wss://...
105
+
106
+ paseo wss://paseo.ibp.network
107
+ ├─ paseo-asset-hub [1000] wss://...
108
+ └─ paseo-people [1004] wss://...
109
+
110
+ my-solo-chain wss://...
111
+ ```
112
+
113
+ All built-in system parachains are preconfigured with their relay chain and parachain ID. When adding a custom parachain with `--relay`, the CLI auto-detects the parachain ID from on-chain `ParachainInfo` storage. Use `--parachain-id` to set it explicitly if auto-detection is not available.
114
+
115
+ Removing a relay chain that has parachains prints a warning listing the orphaned chains. The parachains remain in the config and can be re-associated later.
116
+
117
+ #### Selecting a chain
118
+
119
+ Every chain-consuming command must specify a chain explicitly — either with the global `--chain <name>` flag or with a dotpath chain prefix. There is no hidden default; running a command without a chain errors out with a message listing the configured chains.
120
+
121
+ ```bash
122
+ # Via --chain flag
123
+ dot query.System.Number --chain polkadot
124
+
125
+ # Via dotpath chain prefix
126
+ dot polkadot.query.System.Number
127
+
128
+ # Both at once errors
129
+ dot polkadot.query.System.Number --chain polkadot # ✗ errors
130
+ ```
131
+
132
+ Chain names are case-insensitive. The prefix form also works with the space-separated syntax (`dot query polkadot.System.Account ...`).
133
+
134
+ #### Export/import chain configuration
135
+
136
+ Export and import chain configurations for backup, sharing across machines, or team collaboration. Metadata is not included — re-fetch with `dot chain update --all` after importing.
137
+
138
+ ```bash
139
+ # Export custom chains to stdout (pipe-friendly JSON)
140
+ dot chain export
141
+
142
+ # Export all chains including built-ins
143
+ dot chain export --all
144
+
145
+ # Export specific chains
146
+ dot chain export my-relay my-para
147
+
148
+ # Export to a file
149
+ dot chain export --all --file my-chains.json
150
+
151
+ # Import from a file
152
+ dot chain import my-chains.json
153
+
154
+ # Preview without applying
155
+ dot chain import my-chains.json --dry-run
156
+
157
+ # Overwrite existing chains
158
+ dot chain import my-chains.json --overwrite
159
+
160
+ # Pipe between machines
161
+ ssh remote-dev "dot chain export" | dot chain import -
162
+ ```
163
+
164
+ By default, `export` only includes user-added chains and built-ins with modified RPCs. Use `--all` to include everything. Import skips existing chains unless `--overwrite` is passed, and validates relay references with warnings for missing relays.
165
+
89
166
  ### Manage accounts
90
167
 
91
168
  Dev accounts (Alice, Bob, Charlie, Dave, Eve, Ferdie) are always available for testnets. Create or import your own accounts for any chain.
@@ -129,13 +206,23 @@ MY_SECRET="word1 word2 ..." dot tx System.remark 0xdead --from ci-signer
129
206
  dot account remove my-validator
130
207
  dot account delete my-validator stale-key
131
208
 
209
+ # Export accounts (secrets redacted by default)
210
+ dot account export
211
+ dot account export --include-secrets --file backup.json
212
+ dot account export --watch-only
213
+
214
+ # Batch-import accounts from a file
215
+ dot account import --file team-accounts.json
216
+ dot account import --file accounts.json --dry-run
217
+ dot account import --file accounts.json --overwrite
218
+
132
219
  # Inspect an account — show public key and SS58 address
133
220
  dot account inspect alice
134
221
  dot account alice # shorthand (same as inspect)
135
222
  dot account inspect 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
136
223
  dot account inspect 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
137
224
  dot account inspect alice --prefix 0 # Polkadot mainnet prefix
138
- dot account inspect alice --output json # JSON output
225
+ dot account inspect alice --json # JSON output
139
226
  ```
140
227
 
141
228
  #### Watch-only accounts
@@ -166,7 +253,18 @@ dot query System.Account treasury
166
253
  dot tx Balances.transferKeepAlive bob 1000000000000 --from alice
167
254
  ```
168
255
 
169
- Resolution order: dev account name > stored account name > SS58 address > hex public key. If the input doesn't match any, the CLI shows an error listing available account names.
256
+ Resolution order: dev account name > stored account name > SS58 address > hex public key. If the input doesn't match any, the CLI shows an error listing all available account names alphabetically, one per line. When the input is close to an existing name, a "Did you mean?" suggestion is included:
257
+
258
+ ```
259
+ Error: Unknown account or address "people-sudo-signer".
260
+ Did you mean: people-paseo-sudo?
261
+ Available accounts:
262
+ - alice
263
+ - bob
264
+ - charlie
265
+ - people-paseo-sudo
266
+ - ...
267
+ ```
170
268
 
171
269
  #### Inspect accounts
172
270
 
@@ -195,7 +293,7 @@ dot account inspect alice --prefix 2 # Kusama (prefix 2)
195
293
  JSON output:
196
294
 
197
295
  ```bash
198
- dot account inspect alice --output json
296
+ dot account inspect alice --json
199
297
  # {"publicKey":"0xd435...a27d","ss58":"5Grw...utQY","prefix":42,"name":"Alice"}
200
298
  ```
201
299
 
@@ -247,6 +345,38 @@ dot account derive treasury treasury-staking --path //staking
247
345
 
248
346
  **Known limitation:** Hex seed import (`--secret 0x...`) does not work from the command line. The CLI argument parser (`cac`) interprets `0x`-prefixed values as JavaScript numbers, which loses precision for 32-byte seeds. Use a BIP39 mnemonic instead. If you need to import a raw seed programmatically, write it directly to `~/.polkadot/accounts.json`.
249
347
 
348
+ #### Export/import accounts
349
+
350
+ Export and import accounts for backup, sharing, or bootstrapping CI environments. Secrets are **redacted by default** — safe to share or commit.
351
+
352
+ ```bash
353
+ # Export accounts (secrets redacted by default)
354
+ dot account export
355
+
356
+ # Export specific accounts
357
+ dot account export treasury my-validator
358
+
359
+ # Include secrets (explicit opt-in, prints warning)
360
+ dot account export --include-secrets --file backup.json
361
+
362
+ # Export only watch-only accounts (always safe)
363
+ dot account export --watch-only
364
+
365
+ # Batch-import accounts from a file
366
+ dot account import --file team-accounts.json
367
+
368
+ # Preview without applying
369
+ dot account import --file accounts.json --dry-run
370
+
371
+ # Overwrite existing accounts
372
+ dot account import --file accounts.json --overwrite
373
+
374
+ # Pipe from another machine
375
+ ssh remote-dev "dot account export --watch-only" | dot account import --file /dev/stdin
376
+ ```
377
+
378
+ Security: default export replaces mnemonic/seed with `"<redacted>"`. `--include-secrets` is required for actual secrets. Env-backed accounts export the variable *name* (e.g. `{"env": "MY_SECRET"}`), never the value. Redacted accounts import as watch-only (public key preserved, no signing capability). The existing single-account `import` (`--secret`/`--env`) is unchanged — batch import uses `--file` to distinguish.
379
+
250
380
  ### Chain prefix
251
381
 
252
382
  Instead of the `--chain` flag, you can prefix any target with the chain name using dot notation:
@@ -259,9 +389,9 @@ dot inspect kusama.System
259
389
  dot inspect kusama.System.Account
260
390
  ```
261
391
 
262
- Chain names are case-insensitive — `Polkadot.System.Account`, `POLKADOT.System.Account`, and `polkadot.System.Account` all resolve the same way. The same applies to `--chain Polkadot` and `dot chain default Polkadot`.
392
+ Chain names are case-insensitive — `Polkadot.System.Account`, `POLKADOT.System.Account`, and `polkadot.System.Account` all resolve the same way. The same applies to `--chain Polkadot`.
263
393
 
264
- The `--chain` flag and default chain still work as before. If both a chain prefix and `--chain` flag are provided, the CLI errors.
394
+ Every invocation must specify a chain explicitly: either via a dotpath prefix (as above) or via `--chain <name>`. If both are provided, the CLI errors.
265
395
 
266
396
  ### Space-separated syntax
267
397
 
@@ -306,7 +436,7 @@ dot query people-preview.ChunksManager.Chunks R2e9 1
306
436
 
307
437
  # Pipe-safe — stdout is clean data, progress messages go to stderr
308
438
  dot query System.Account --dump | jq '.[0].value.data.free'
309
- dot query System.Number --output json | jq '.+1'
439
+ dot query System.Number --json | jq '.+1'
310
440
 
311
441
  # Query a specific chain using chain prefix
312
442
  dot query kusama.System.Account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
@@ -351,7 +481,7 @@ dot const System.SS58Prefix --chain kusama
351
481
  dot const kusama.Balances.ExistentialDeposit
352
482
 
353
483
  # Pipe-safe — stdout is clean JSON, progress messages go to stderr
354
- dot const Balances.ExistentialDeposit --output json | jq
484
+ dot const Balances.ExistentialDeposit --json | jq
355
485
  ```
356
486
 
357
487
  ### Inspect metadata
@@ -420,7 +550,6 @@ dot apis.Core.version --help
420
550
  Runtime API info requires v15 metadata. If `dot apis` shows 0 APIs, update the cached metadata:
421
551
 
422
552
  ```bash
423
- dot chain update # default chain
424
553
  dot chain update people-paseo # specific chain
425
554
  dot chain update --all # all configured chains
426
555
  ```
@@ -525,21 +654,21 @@ Decode a hex-encoded call into a YAML or JSON file that is compatible with [file
525
654
 
526
655
  ```bash
527
656
  # Decode a raw hex call to YAML
528
- dot tx.0x0001076465616462656566 --yaml
657
+ dot tx.0x0001076465616462656566 --to-yaml
529
658
 
530
659
  # Decode a raw hex call to JSON
531
- dot tx.0x0001076465616462656566 --json
660
+ dot tx.0x0001076465616462656566 --to-json
532
661
 
533
662
  # Encode a named call and output as YAML
534
- dot tx.System.remark 0xdeadbeef --yaml
663
+ dot tx.System.remark 0xdeadbeef --to-yaml
535
664
 
536
665
  # Round-trip: encode to hex, decode to YAML, re-encode from file
537
- dot tx.System.remark 0xdeadbeef --encode # 0x0001076465616462656566
538
- dot tx.0x0001076465616462656566 --yaml > remark.yaml
539
- dot ./remark.yaml --encode # same hex
666
+ dot tx.System.remark 0xdeadbeef --encode # 0x0001076465616462656566
667
+ dot tx.0x0001076465616462656566 --to-yaml > remark.yaml
668
+ dot ./remark.yaml --encode # same hex
540
669
  ```
541
670
 
542
- `--yaml` / `--json` are mutually exclusive with each other and with `--encode` and `--dry-run`.
671
+ `--to-yaml` / `--to-json` are mutually exclusive with each other and with `--encode` and `--dry-run`.
543
672
 
544
673
  Both dry-run and submission display the encoded call hex and a decoded human-readable form:
545
674
 
@@ -627,7 +756,7 @@ Override low-level transaction parameters. Useful for rapid-fire submission (cus
627
756
  | `--nonce <n>` | non-negative integer | Override the auto-detected nonce |
628
757
  | `--tip <amount>` | non-negative integer (planck) | Priority tip for the transaction pool |
629
758
  | `--mortality <spec>` | `immortal` or period (min 4) | Transaction mortality window |
630
- | `--at <block>` | `best`, `finalized`, or 0x-prefixed block hash | Block state to validate against |
759
+ | `--at <block>` | 0x-prefixed block hash | Block hash to validate against (defaults to finalized) |
631
760
 
632
761
  ```bash
633
762
  # Fire-and-forget: submit two txs in rapid succession with manual nonces
@@ -643,14 +772,72 @@ dot tx System.remark 0xdead --from alice --mortality immortal
643
772
  # Set a custom mortality period (rounds up to nearest power of two)
644
773
  dot tx System.remark 0xdead --from alice --mortality 128
645
774
 
646
- # Validate against the best (not finalized) block
647
- dot tx System.remark 0xdead --from alice --at best
775
+ # Validate against a specific block hash
776
+ dot tx System.remark 0xdead --from alice --at 0x1234...abcd
648
777
 
649
778
  # Combine: rapid-fire with tip and broadcast-only
650
779
  dot tx System.remark 0xdead --from alice --nonce 5 --tip 500000 --wait broadcast
651
780
  ```
652
781
 
653
- When set, nonce / tip / mortality / at are shown in both `--dry-run` and submission output. These flags are silently ignored with `--encode`, `--yaml`, and `--json` (which return before signing).
782
+ When set, nonce / tip / mortality / at are shown in both `--dry-run` and submission output. These flags are silently ignored with `--encode`, `--to-yaml`, and `--to-json` (which return before signing).
783
+
784
+ #### Pay fees in an alternative asset
785
+
786
+ On asset-hub-style chains (Polkadot Asset Hub, Paseo Asset Hub, etc.) the `ChargeAssetTxPayment` signed extension lets a transaction pay its fees in a non-native asset. Use `--asset <json>` to select the asset — the value is an XCM location (JSON) identifying the asset, which the runtime's asset-conversion pool swaps for native tokens at dispatch time.
787
+
788
+ ```bash
789
+ # Pay fees in USDT (asset id 1337, PalletInstance 50) on Polkadot Asset Hub
790
+ dot tx Balances.transfer_keep_alive 5FHneW46... 1000000000000 \
791
+ --from alice --chain polkadot-asset-hub \
792
+ --asset '{"parents":0,"interior":{"type":"X2","value":[{"type":"PalletInstance","value":50},{"type":"GeneralIndex","value":"1337"}]}}'
793
+
794
+ # Dry-run to see the native-denominated fee estimate
795
+ dot tx Balances.transfer_keep_alive 5FHneW46... 1000000000000 \
796
+ --from alice --chain polkadot-asset-hub --dry-run \
797
+ --asset '{"parents":0,"interior":{"type":"X2","value":[{"type":"PalletInstance","value":50},{"type":"GeneralIndex","value":"1337"}]}}'
798
+ ```
799
+
800
+ The `--asset` echo is included in dry-run and submission output (and `--json`). A few things to know:
801
+
802
+ - The target chain must expose `ChargeAssetTxPayment` in its signed extensions — asset-hub-style chains do; plain relay chains don't, and `--asset` is silently ignored on those.
803
+ - The estimated fee shown is **native-denominated**. The on-chain asset-conversion pool determines the actual asset amount charged at execution time.
804
+ - `--asset` is unnecessary (and not compatible) with `--unsigned`: unsigned transactions default `ChargeAssetTxPayment` to zero tip / no asset.
805
+ - Combine freely with `--tip`, `--nonce`, `--mortality`, and `--at`. `--tip` is encoded inside the asset-payment extension alongside the asset id.
806
+
807
+ Under the hood, the CLI routes the asset through its custom signed-extension pipeline rather than polkadot-api's native `asset` option — this works around a papi compatibility check that rejects XCM Location JSON on the unsafe API path.
808
+
809
+ #### Unsigned/authorized transactions
810
+
811
+ Submit transactions without a signer using `--unsigned`. This is for calls authorized by on-chain mechanisms (e.g. the `AuthorizeCall` extension) rather than cryptographic signatures — typically governance-authorized calls on chains like the People chain.
812
+
813
+ ```bash
814
+ # Submit an authorized call on the People chain
815
+ dot tx People.create_people_collection --unsigned --chain people
816
+
817
+ # Dry-run to inspect before submitting
818
+ dot tx People.create_people_collection --unsigned --chain people --dry-run
819
+
820
+ # Encode the full general transaction bytes
821
+ dot tx People.create_people_collection --unsigned --chain people --encode
822
+
823
+ # With raw hex call data
824
+ dot tx 0x3306 --unsigned --chain people
825
+
826
+ # JSON output for scripting
827
+ dot tx People.create_people_collection --unsigned --chain people --json
828
+ ```
829
+
830
+ The CLI constructs a v5 general transaction with all extension values auto-defaulted (`VerifySignature::Disabled`, `Era::Immortal`, nonce `0`, tip `0`, etc.). Override individual extensions with `--ext` if needed.
831
+
832
+ `--unsigned` is mutually exclusive with `--from`, `--nonce`, `--tip`, and `--mortality`. File-based input supports `unsigned: true`:
833
+
834
+ ```yaml
835
+ chain: people
836
+ unsigned: true
837
+ tx:
838
+ People:
839
+ create_people_collection: null
840
+ ```
654
841
 
655
842
  ### File-based commands
656
843
 
@@ -837,7 +1024,7 @@ CALL=$(dot tx.System.remark 0xdead --encode)
837
1024
  dot ./xcm-transact.yaml --var CALL=$CALL --encode
838
1025
  ```
839
1026
 
840
- All existing flags work with file input — `--chain` overrides the file's `chain:` field, `--from`, `--dry-run`, `--encode`, `--yaml`, `--json`, `--output`, etc. behave identically to inline commands.
1027
+ All existing flags work with file input — `--chain` overrides the file's `chain:` field, `--from`, `--dry-run`, `--encode`, `--to-yaml`, `--to-json`, `--json`, `--output`, etc. behave identically to inline commands.
841
1028
 
842
1029
  ### Compute hashes
843
1030
 
@@ -857,7 +1044,7 @@ dot hash keccak256 --file ./data.bin
857
1044
  echo -n "hello" | dot hash sha256 --stdin
858
1045
 
859
1046
  # JSON output
860
- dot hash blake2b256 0xdeadbeef --output json
1047
+ dot hash blake2b256 0xdeadbeef --json
861
1048
  ```
862
1049
 
863
1050
  Run `dot hash` with no arguments to see all available algorithms.
@@ -880,7 +1067,7 @@ dot sign --file ./payload.bin --from alice
880
1067
  echo -n "hello" | dot sign --stdin --from alice
881
1068
 
882
1069
  # JSON output (for scripting)
883
- dot sign "hello" --from alice --output json
1070
+ dot sign "hello" --from alice --json
884
1071
  ```
885
1072
 
886
1073
  Output shows the crypto type, message bytes in hex, raw signature, and an `Enum` value directly pasteable into tx arguments (e.g. `Sr25519(0x...)`).
@@ -908,7 +1095,7 @@ dot parachain 2004 --type sibling
908
1095
  dot parachain 1000 --prefix 0
909
1096
 
910
1097
  # JSON output
911
- dot parachain 1000 --output json
1098
+ dot parachain 1000 --json
912
1099
  ```
913
1100
 
914
1101
  Run `dot parachain` with no arguments to see usage and examples.
@@ -928,7 +1115,7 @@ dot verifiable alice --context candidate
928
1115
  dot verifiable alice --context pps
929
1116
 
930
1117
  # JSON output (for scripting)
931
- dot verifiable alice --context candidate --output json
1118
+ dot verifiable alice --context candidate --json
932
1119
  ```
933
1120
 
934
1121
  The derivation flow:
@@ -980,20 +1167,48 @@ dot tx.System.remark 0xdead # shows call help (no error)
980
1167
  | Flag | Description |
981
1168
  |------|-------------|
982
1169
  | `--help` | Show help (global or command-specific) |
983
- | `--chain <name>` | Target chain (default from config) |
984
- | `--rpc <url>` | Override RPC endpoint(s) for this call (repeat for fallback) |
985
- | `--light-client` | Use Smoldot light client |
986
- | `--output json` | Raw JSON output (default: pretty) |
1170
+ | `--chain <name>` | Target chain (required unless a dotpath chain prefix is used) |
1171
+ | `--rpc <url>` | Override RPC endpoint(s) for this call (repeat for fallback). Always fetches fresh metadata, bypassing the cache |
1172
+
1173
+ | `--json` | Structured JSON output (shorthand for `--output json`) |
1174
+ | `--output json` | Structured JSON output |
987
1175
  | `--dump` | Dump all entries of a storage map (required for keyless map queries) |
988
1176
  | `-w, --wait <level>` | Tx wait level: `broadcast`, `best-block` / `best`, `finalized` (default) |
989
1177
 
1178
+ ### Structured JSON output
1179
+
1180
+ Every command supports `--json` for machine-readable output. This works on data queries, metadata inspection, account management, chain configuration, and transaction submission:
1181
+
1182
+ ```bash
1183
+ dot inspect --json # All pallets as JSON
1184
+ dot inspect Balances --json # Pallet detail with storage, constants, calls, events, errors
1185
+ dot chain list --json # Configured chains
1186
+ dot account list --json # Dev and stored accounts
1187
+ dot account create my-key --json # New account details (mnemonic warning on stderr)
1188
+ dot tx.System.remark 0xdead --encode --json # Encoded call hex wrapped in JSON
1189
+ dot events.Balances --json # Event listing with field signatures
1190
+ dot const.System --json # Constant listing with types
1191
+ ```
1192
+
1193
+ For transaction submission, `--json` emits NDJSON (one JSON object per lifecycle event):
1194
+
1195
+ ```bash
1196
+ dot tx.System.remark 0xdead --from alice --json
1197
+ # {"event":"signed","txHash":"0x..."}
1198
+ # {"event":"broadcasted","txHash":"0x..."}
1199
+ # {"event":"finalized","blockNumber":123,"blockHash":"0x...","ok":true,"events":[...]}
1200
+ ```
1201
+
990
1202
  ### Pipe-safe output
991
1203
 
992
- All commands follow Unix conventions: **data goes to stdout, progress goes to stderr**. This means you can safely pipe `--output json` into `jq` or other tools without progress messages ("Fetching metadata...", spinner output, "Connecting...") corrupting the data stream:
1204
+ All commands follow Unix conventions: **data goes to stdout, progress goes to stderr**. This means you can safely pipe `--json` into `jq` or other tools without progress messages ("Fetching metadata...", spinner output, "Connecting...") corrupting the data stream:
993
1205
 
994
1206
  ```bash
995
- dot const System.SS58Prefix --output json | jq '.+1'
996
- dot query System.Number --output json | jq
1207
+ dot const System.SS58Prefix --json | jq '.+1'
1208
+ dot query System.Number --json | jq
1209
+ dot chain list --json | jq '.chains[].name'
1210
+ dot account list --json | jq '.stored[].address'
1211
+ dot inspect --json | jq '.pallets[] | select(.events > 10) | .name'
997
1212
  ```
998
1213
 
999
1214
  In an interactive terminal, both streams render together so you see progress and results normally.
@@ -1024,7 +1239,7 @@ dot apis.Core.<Tab> # → apis.Core.version, ...
1024
1239
  dot polkadot.<Tab> # → polkadot.query, polkadot.tx, ..., polkadot.apis
1025
1240
  dot --chain <Tab> # → polkadot, paseo, ...
1026
1241
  dot --from <Tab> # → alice, bob, ..., stored account names
1027
- dot chain <Tab> # → add, remove, update, list, default
1242
+ dot chain <Tab> # → add, remove, update, list
1028
1243
  ```
1029
1244
 
1030
1245
  Completions are context-aware: `query.` shows pallets with storage items, `tx.` shows pallets with calls, `events.` and `errors.` filter accordingly, `apis.` shows runtime API names. Chain prefix paths like `polkadot.query.System.` work at any depth.
@@ -1073,7 +1288,7 @@ Config and metadata caches live in `~/.polkadot/`:
1073
1288
 
1074
1289
  ```
1075
1290
  ~/.polkadot/
1076
- ├── config.json # chains and default chain
1291
+ ├── config.json # configured chains
1077
1292
  ├── accounts.json # stored accounts (⚠️ secrets are NOT encrypted — see below)
1078
1293
  ├── update-check.json # cached update check result
1079
1294
  └── chains/
@@ -1085,7 +1300,7 @@ Config and metadata caches live in `~/.polkadot/`:
1085
1300
 
1086
1301
  ## Environment compatibility
1087
1302
 
1088
- The CLI works in Node.js, Bun, and sandboxed runtimes (e.g. LLM tool-use / MCP environments) that lack a native `globalThis.WebSocket`. WebSocket connections use the [`ws`](https://github.com/websockets/ws) package explicitly, so no global polyfill is required.
1303
+ The CLI works in Node.js (v22+), Bun, and sandboxed runtimes (e.g. LLM tool-use / MCP environments). WebSocket connections use the native `WebSocket` implementation provided by the runtime no external WebSocket package is required.
1089
1304
 
1090
1305
  ## Development
1091
1306