polkadot-cli 1.11.0 → 1.13.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 +174 -51
  2. package/dist/cli.mjs +1334 -280
  3. package/package.json +9 -10
package/README.md CHANGED
@@ -15,31 +15,34 @@ 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
27
+ - ✅ Message signing — sign arbitrary bytes with account keypairs for use as `MultiSignature` arguments
28
+ - ✅ Bandersnatch member keys — derive Ring VRF member keys from mnemonics for on-chain member sets
26
29
 
27
30
  ### Preconfigured chains
28
31
 
29
- | Network | Chain | Light client |
30
- |---------|-------|:---:|
31
- | Polkadot | `polkadot` (relay, default) | yes |
32
- | | `polkadot-asset-hub` | yes |
33
- | | `polkadot-bridge-hub` | yes |
34
- | | `polkadot-collectives` | yes |
35
- | | `polkadot-coretime` | yes |
36
- | | `polkadot-people` | yes |
37
- | Paseo (testnet) | `paseo` (relay) | yes |
38
- | | `paseo-asset-hub` | yes |
39
- | | `paseo-bridge-hub` | — |
40
- | | `paseo-collectives` | — |
41
- | | `paseo-coretime` | yes |
42
- | | `paseo-people` | yes |
32
+ | Network | Chain |
33
+ |---------|-------|
34
+ | Polkadot | `polkadot` (relay, default) |
35
+ | | `polkadot-asset-hub` |
36
+ | | `polkadot-bridge-hub` |
37
+ | | `polkadot-collectives` |
38
+ | | `polkadot-coretime` |
39
+ | | `polkadot-people` |
40
+ | Paseo (testnet) | `paseo` (relay) |
41
+ | | `paseo-asset-hub` |
42
+ | | `paseo-bridge-hub` |
43
+ | | `paseo-collectives` |
44
+ | | `paseo-coretime` |
45
+ | | `paseo-people` |
43
46
 
44
47
  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.
45
48
 
@@ -66,10 +69,13 @@ dot chain add kusama --rpc wss://kusama-rpc.polkadot.io
66
69
  # Add a chain with fallback RPCs (repeat --rpc for each endpoint)
67
70
  dot chain add kusama --rpc wss://kusama-rpc.polkadot.io --rpc wss://kusama-rpc.dwellir.com
68
71
 
69
- # Add a chain via light client
70
- dot chain add westend --light-client
72
+ # Add a parachain under a relay (auto-detects parachain ID)
73
+ dot chain add local-asset-hub --rpc ws://localhost:9945 --relay local-relay
71
74
 
72
- # List configured chains
75
+ # Add a parachain with explicit parachain ID
76
+ dot chain add my-para --rpc wss://rpc.example.com --relay polkadot --parachain-id 2000
77
+
78
+ # List configured chains (shows relay/parachain hierarchy)
73
79
  dot chain list
74
80
 
75
81
  # Re-fetch metadata after a runtime upgrade
@@ -84,6 +90,31 @@ dot chain default kusama
84
90
  dot chain remove westend
85
91
  ```
86
92
 
93
+ #### Chain topology
94
+
95
+ `dot chain list` displays chains as a tree, grouping parachains under their parent relay:
96
+
97
+ ```
98
+ Configured Chains
99
+
100
+ polkadot (default) wss://polkadot.ibp.network
101
+ ├─ polkadot-asset-hub [1000] wss://...
102
+ ├─ polkadot-bridge-hub [1002] wss://...
103
+ ├─ polkadot-collectives [1001] wss://...
104
+ ├─ polkadot-coretime [1005] wss://...
105
+ └─ polkadot-people [1004] wss://...
106
+
107
+ paseo wss://paseo.ibp.network
108
+ ├─ paseo-asset-hub [1000] wss://...
109
+ └─ paseo-people [1004] wss://...
110
+
111
+ my-solo-chain wss://...
112
+ ```
113
+
114
+ 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.
115
+
116
+ 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.
117
+
87
118
  ### Manage accounts
88
119
 
89
120
  Dev accounts (Alice, Bob, Charlie, Dave, Eve, Ferdie) are always available for testnets. Create or import your own accounts for any chain.
@@ -133,7 +164,7 @@ dot account alice # shorthand (same as inspect)
133
164
  dot account inspect 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
134
165
  dot account inspect 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
135
166
  dot account inspect alice --prefix 0 # Polkadot mainnet prefix
136
- dot account inspect alice --output json # JSON output
167
+ dot account inspect alice --json # JSON output
137
168
  ```
138
169
 
139
170
  #### Watch-only accounts
@@ -164,7 +195,18 @@ dot query System.Account treasury
164
195
  dot tx Balances.transferKeepAlive bob 1000000000000 --from alice
165
196
  ```
166
197
 
167
- 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.
198
+ 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:
199
+
200
+ ```
201
+ Error: Unknown account or address "people-sudo-signer".
202
+ Did you mean: people-paseo-sudo?
203
+ Available accounts:
204
+ - alice
205
+ - bob
206
+ - charlie
207
+ - people-paseo-sudo
208
+ - ...
209
+ ```
168
210
 
169
211
  #### Inspect accounts
170
212
 
@@ -193,7 +235,7 @@ dot account inspect alice --prefix 2 # Kusama (prefix 2)
193
235
  JSON output:
194
236
 
195
237
  ```bash
196
- dot account inspect alice --output json
238
+ dot account inspect alice --json
197
239
  # {"publicKey":"0xd435...a27d","ss58":"5Grw...utQY","prefix":42,"name":"Alice"}
198
240
  ```
199
241
 
@@ -296,15 +338,15 @@ dot query System.Account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
296
338
  # Map without key — shows help/usage (use --dump to fetch all entries)
297
339
  dot query System.Account
298
340
 
299
- # Dump all map entries (requires --dump, default limit: 100)
300
- dot query System.Account --dump --limit 10
341
+ # Dump all map entries (requires --dump)
342
+ dot query System.Account --dump
301
343
 
302
344
  # Enum variant as map key (case-insensitive)
303
345
  dot query people-preview.ChunksManager.Chunks R2e9 1
304
346
 
305
347
  # Pipe-safe — stdout is clean data, progress messages go to stderr
306
- dot query System.Account --dump --limit 5 | jq '.[0].value.data.free'
307
- dot query System.Number --output json | jq '.+1'
348
+ dot query System.Account --dump | jq '.[0].value.data.free'
349
+ dot query System.Number --json | jq '.+1'
308
350
 
309
351
  # Query a specific chain using chain prefix
310
352
  dot query kusama.System.Account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
@@ -324,12 +366,9 @@ dot query Staking.ErasStakers 100 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKut
324
366
  dot query Staking.ErasStakers 100
325
367
 
326
368
  # No keys — requires --dump (safety net for large maps)
327
- dot query Staking.ErasStakers --dump --limit 10
369
+ dot query Staking.ErasStakers --dump
328
370
  ```
329
371
 
330
- The `--limit` option applies to partial key results just like it does for
331
- `--dump` (default: 100, use `--limit 0` for unlimited).
332
-
333
372
  #### Output formatting
334
373
 
335
374
  Query results automatically convert on-chain types for readability:
@@ -352,7 +391,7 @@ dot const System.SS58Prefix --chain kusama
352
391
  dot const kusama.Balances.ExistentialDeposit
353
392
 
354
393
  # Pipe-safe — stdout is clean JSON, progress messages go to stderr
355
- dot const Balances.ExistentialDeposit --output json | jq
394
+ dot const Balances.ExistentialDeposit --json | jq
356
395
  ```
357
396
 
358
397
  ### Inspect metadata
@@ -526,21 +565,21 @@ Decode a hex-encoded call into a YAML or JSON file that is compatible with [file
526
565
 
527
566
  ```bash
528
567
  # Decode a raw hex call to YAML
529
- dot tx.0x0001076465616462656566 --yaml
568
+ dot tx.0x0001076465616462656566 --to-yaml
530
569
 
531
570
  # Decode a raw hex call to JSON
532
- dot tx.0x0001076465616462656566 --json
571
+ dot tx.0x0001076465616462656566 --to-json
533
572
 
534
573
  # Encode a named call and output as YAML
535
- dot tx.System.remark 0xdeadbeef --yaml
574
+ dot tx.System.remark 0xdeadbeef --to-yaml
536
575
 
537
576
  # Round-trip: encode to hex, decode to YAML, re-encode from file
538
- dot tx.System.remark 0xdeadbeef --encode # 0x0001076465616462656566
539
- dot tx.0x0001076465616462656566 --yaml > remark.yaml
540
- dot ./remark.yaml --encode # same hex
577
+ dot tx.System.remark 0xdeadbeef --encode # 0x0001076465616462656566
578
+ dot tx.0x0001076465616462656566 --to-yaml > remark.yaml
579
+ dot ./remark.yaml --encode # same hex
541
580
  ```
542
581
 
543
- `--yaml` / `--json` are mutually exclusive with each other and with `--encode` and `--dry-run`.
582
+ `--to-yaml` / `--to-json` are mutually exclusive with each other and with `--encode` and `--dry-run`.
544
583
 
545
584
  Both dry-run and submission display the encoded call hex and a decoded human-readable form:
546
585
 
@@ -628,7 +667,7 @@ Override low-level transaction parameters. Useful for rapid-fire submission (cus
628
667
  | `--nonce <n>` | non-negative integer | Override the auto-detected nonce |
629
668
  | `--tip <amount>` | non-negative integer (planck) | Priority tip for the transaction pool |
630
669
  | `--mortality <spec>` | `immortal` or period (min 4) | Transaction mortality window |
631
- | `--at <block>` | `best`, `finalized`, or 0x-prefixed block hash | Block state to validate against |
670
+ | `--at <block>` | 0x-prefixed block hash | Block hash to validate against (defaults to finalized) |
632
671
 
633
672
  ```bash
634
673
  # Fire-and-forget: submit two txs in rapid succession with manual nonces
@@ -644,14 +683,14 @@ dot tx System.remark 0xdead --from alice --mortality immortal
644
683
  # Set a custom mortality period (rounds up to nearest power of two)
645
684
  dot tx System.remark 0xdead --from alice --mortality 128
646
685
 
647
- # Validate against the best (not finalized) block
648
- dot tx System.remark 0xdead --from alice --at best
686
+ # Validate against a specific block hash
687
+ dot tx System.remark 0xdead --from alice --at 0x1234...abcd
649
688
 
650
689
  # Combine: rapid-fire with tip and broadcast-only
651
690
  dot tx System.remark 0xdead --from alice --nonce 5 --tip 500000 --wait broadcast
652
691
  ```
653
692
 
654
- 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).
693
+ 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).
655
694
 
656
695
  ### File-based commands
657
696
 
@@ -838,7 +877,7 @@ CALL=$(dot tx.System.remark 0xdead --encode)
838
877
  dot ./xcm-transact.yaml --var CALL=$CALL --encode
839
878
  ```
840
879
 
841
- 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.
880
+ 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.
842
881
 
843
882
  ### Compute hashes
844
883
 
@@ -858,11 +897,36 @@ dot hash keccak256 --file ./data.bin
858
897
  echo -n "hello" | dot hash sha256 --stdin
859
898
 
860
899
  # JSON output
861
- dot hash blake2b256 0xdeadbeef --output json
900
+ dot hash blake2b256 0xdeadbeef --json
862
901
  ```
863
902
 
864
903
  Run `dot hash` with no arguments to see all available algorithms.
865
904
 
905
+ ### Sign messages
906
+
907
+ Sign arbitrary messages with an account keypair. Output is a `Sr25519(0x...)` value directly usable as a `MultiSignature` enum argument in transaction calls.
908
+
909
+ ```bash
910
+ # Sign a text message
911
+ dot sign "hello world" --from alice
912
+
913
+ # Sign hex-encoded bytes
914
+ dot sign 0xdeadbeef --from alice
915
+
916
+ # Sign file contents
917
+ dot sign --file ./payload.bin --from alice
918
+
919
+ # Read from stdin
920
+ echo -n "hello" | dot sign --stdin --from alice
921
+
922
+ # JSON output (for scripting)
923
+ dot sign "hello" --from alice --json
924
+ ```
925
+
926
+ Output shows the crypto type, message bytes in hex, raw signature, and an `Enum` value directly pasteable into tx arguments (e.g. `Sr25519(0x...)`).
927
+
928
+ Use `--type` to select the signature algorithm (default: `sr25519`). Run `dot sign` with no arguments to see usage and examples.
929
+
866
930
  ### Parachain sovereign accounts
867
931
 
868
932
  Derive the sovereign account addresses for a parachain. These are deterministic accounts derived from a parachain ID — no chain connection required.
@@ -884,11 +948,43 @@ dot parachain 2004 --type sibling
884
948
  dot parachain 1000 --prefix 0
885
949
 
886
950
  # JSON output
887
- dot parachain 1000 --output json
951
+ dot parachain 1000 --json
888
952
  ```
889
953
 
890
954
  Run `dot parachain` with no arguments to see usage and examples.
891
955
 
956
+ ### Bandersnatch member keys
957
+
958
+ Derive Bandersnatch member keys from account mnemonics for on-chain member set registration (personhood proofs, Ring VRF). Uses the [`verifiablejs`](https://github.com/paritytech/verifiablejs) WASM library.
959
+
960
+ ```bash
961
+ # Derive unkeyed member key (lite person)
962
+ dot verifiable alice
963
+
964
+ # Derive keyed member key (full person — "candidate" context)
965
+ dot verifiable alice --context candidate
966
+
967
+ # Arbitrary context string
968
+ dot verifiable alice --context pps
969
+
970
+ # JSON output (for scripting)
971
+ dot verifiable alice --context candidate --json
972
+ ```
973
+
974
+ The derivation flow:
975
+
976
+ ```
977
+ Mnemonic → mnemonicToEntropy() → blake2b256(entropy, context?) → member_from_entropy() → 32-byte member key
978
+ ```
979
+
980
+ - **Unkeyed** (no `--context`): `blake2b256(entropy)` — used for lite person registration
981
+ - **With context** (e.g. `--context candidate`): `blake2b256(entropy, key="candidate")` — used for full person registration. The `--context` value is passed as the raw UTF-8 bytes of the blake2b key parameter.
982
+ - Both 12-word and 24-word mnemonics are supported
983
+
984
+ Derived keys are saved to the account store. For stored accounts, saved keys appear in `dot account inspect` output. When creating a new account with `dot account create`, both unkeyed and `candidate` keys are automatically derived and saved.
985
+
986
+ Run `dot verifiable` with no arguments to see usage and the full derivation diagram.
987
+
892
988
  ### Getting help
893
989
 
894
990
  Every command supports `--help` to show its detailed usage, available actions, and examples:
@@ -926,19 +1022,46 @@ dot tx.System.remark 0xdead # shows call help (no error)
926
1022
  | `--help` | Show help (global or command-specific) |
927
1023
  | `--chain <name>` | Target chain (default from config) |
928
1024
  | `--rpc <url>` | Override RPC endpoint(s) for this call (repeat for fallback) |
929
- | `--light-client` | Use Smoldot light client |
930
- | `--output json` | Raw JSON output (default: pretty) |
1025
+
1026
+ | `--json` | Structured JSON output (shorthand for `--output json`) |
1027
+ | `--output json` | Structured JSON output |
931
1028
  | `--dump` | Dump all entries of a storage map (required for keyless map queries) |
932
- | `--limit <n>` | Max entries for map queries (0 = unlimited, default: 100) |
933
1029
  | `-w, --wait <level>` | Tx wait level: `broadcast`, `best-block` / `best`, `finalized` (default) |
934
1030
 
1031
+ ### Structured JSON output
1032
+
1033
+ Every command supports `--json` for machine-readable output. This works on data queries, metadata inspection, account management, chain configuration, and transaction submission:
1034
+
1035
+ ```bash
1036
+ dot inspect --json # All pallets as JSON
1037
+ dot inspect Balances --json # Pallet detail with storage, constants, calls, events, errors
1038
+ dot chain list --json # Configured chains
1039
+ dot account list --json # Dev and stored accounts
1040
+ dot account create my-key --json # New account details (mnemonic warning on stderr)
1041
+ dot tx.System.remark 0xdead --encode --json # Encoded call hex wrapped in JSON
1042
+ dot events.Balances --json # Event listing with field signatures
1043
+ dot const.System --json # Constant listing with types
1044
+ ```
1045
+
1046
+ For transaction submission, `--json` emits NDJSON (one JSON object per lifecycle event):
1047
+
1048
+ ```bash
1049
+ dot tx.System.remark 0xdead --from alice --json
1050
+ # {"event":"signed","txHash":"0x..."}
1051
+ # {"event":"broadcasted","txHash":"0x..."}
1052
+ # {"event":"finalized","blockNumber":123,"blockHash":"0x...","ok":true,"events":[...]}
1053
+ ```
1054
+
935
1055
  ### Pipe-safe output
936
1056
 
937
- 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:
1057
+ 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:
938
1058
 
939
1059
  ```bash
940
- dot const System.SS58Prefix --output json | jq '.+1'
941
- dot query System.Number --output json | jq
1060
+ dot const System.SS58Prefix --json | jq '.+1'
1061
+ dot query System.Number --json | jq
1062
+ dot chain list --json | jq '.chains[].name'
1063
+ dot account list --json | jq '.stored[].address'
1064
+ dot inspect --json | jq '.pallets[] | select(.events > 10) | .name'
942
1065
  ```
943
1066
 
944
1067
  In an interactive terminal, both streams render together so you see progress and results normally.
@@ -1030,7 +1153,7 @@ Config and metadata caches live in `~/.polkadot/`:
1030
1153
 
1031
1154
  ## Environment compatibility
1032
1155
 
1033
- 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.
1156
+ 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.
1034
1157
 
1035
1158
  ## Development
1036
1159