polkadot-cli 1.12.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.
- package/README.md +113 -45
- package/dist/cli.mjs +1084 -253
- package/package.json +8 -10
package/README.md
CHANGED
|
@@ -15,11 +15,12 @@ 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 —
|
|
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
|
|
@@ -28,20 +29,20 @@ Ships with Polkadot and all system parachains preconfigured with multiple fallba
|
|
|
28
29
|
|
|
29
30
|
### Preconfigured chains
|
|
30
31
|
|
|
31
|
-
| Network | Chain |
|
|
32
|
-
|
|
33
|
-
| Polkadot | `polkadot` (relay, default) |
|
|
34
|
-
| | `polkadot-asset-hub` |
|
|
35
|
-
| | `polkadot-bridge-hub` |
|
|
36
|
-
| | `polkadot-collectives` |
|
|
37
|
-
| | `polkadot-coretime` |
|
|
38
|
-
| | `polkadot-people` |
|
|
39
|
-
| Paseo (testnet) | `paseo` (relay) |
|
|
40
|
-
| | `paseo-asset-hub` |
|
|
41
|
-
| | `paseo-bridge-hub` |
|
|
42
|
-
| | `paseo-collectives` |
|
|
43
|
-
| | `paseo-coretime` |
|
|
44
|
-
| | `paseo-people` |
|
|
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` |
|
|
45
46
|
|
|
46
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.
|
|
47
48
|
|
|
@@ -68,10 +69,13 @@ dot chain add kusama --rpc wss://kusama-rpc.polkadot.io
|
|
|
68
69
|
# Add a chain with fallback RPCs (repeat --rpc for each endpoint)
|
|
69
70
|
dot chain add kusama --rpc wss://kusama-rpc.polkadot.io --rpc wss://kusama-rpc.dwellir.com
|
|
70
71
|
|
|
71
|
-
# Add a
|
|
72
|
-
dot chain add
|
|
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
|
|
73
74
|
|
|
74
|
-
#
|
|
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)
|
|
75
79
|
dot chain list
|
|
76
80
|
|
|
77
81
|
# Re-fetch metadata after a runtime upgrade
|
|
@@ -86,6 +90,31 @@ dot chain default kusama
|
|
|
86
90
|
dot chain remove westend
|
|
87
91
|
```
|
|
88
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
|
+
|
|
89
118
|
### Manage accounts
|
|
90
119
|
|
|
91
120
|
Dev accounts (Alice, Bob, Charlie, Dave, Eve, Ferdie) are always available for testnets. Create or import your own accounts for any chain.
|
|
@@ -135,7 +164,7 @@ dot account alice # shorthand (same as inspect)
|
|
|
135
164
|
dot account inspect 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
|
|
136
165
|
dot account inspect 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
|
|
137
166
|
dot account inspect alice --prefix 0 # Polkadot mainnet prefix
|
|
138
|
-
dot account inspect alice --
|
|
167
|
+
dot account inspect alice --json # JSON output
|
|
139
168
|
```
|
|
140
169
|
|
|
141
170
|
#### Watch-only accounts
|
|
@@ -166,7 +195,18 @@ dot query System.Account treasury
|
|
|
166
195
|
dot tx Balances.transferKeepAlive bob 1000000000000 --from alice
|
|
167
196
|
```
|
|
168
197
|
|
|
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.
|
|
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
|
+
```
|
|
170
210
|
|
|
171
211
|
#### Inspect accounts
|
|
172
212
|
|
|
@@ -195,7 +235,7 @@ dot account inspect alice --prefix 2 # Kusama (prefix 2)
|
|
|
195
235
|
JSON output:
|
|
196
236
|
|
|
197
237
|
```bash
|
|
198
|
-
dot account inspect alice --
|
|
238
|
+
dot account inspect alice --json
|
|
199
239
|
# {"publicKey":"0xd435...a27d","ss58":"5Grw...utQY","prefix":42,"name":"Alice"}
|
|
200
240
|
```
|
|
201
241
|
|
|
@@ -306,7 +346,7 @@ dot query people-preview.ChunksManager.Chunks R2e9 1
|
|
|
306
346
|
|
|
307
347
|
# Pipe-safe — stdout is clean data, progress messages go to stderr
|
|
308
348
|
dot query System.Account --dump | jq '.[0].value.data.free'
|
|
309
|
-
dot query System.Number --
|
|
349
|
+
dot query System.Number --json | jq '.+1'
|
|
310
350
|
|
|
311
351
|
# Query a specific chain using chain prefix
|
|
312
352
|
dot query kusama.System.Account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
|
|
@@ -351,7 +391,7 @@ dot const System.SS58Prefix --chain kusama
|
|
|
351
391
|
dot const kusama.Balances.ExistentialDeposit
|
|
352
392
|
|
|
353
393
|
# Pipe-safe — stdout is clean JSON, progress messages go to stderr
|
|
354
|
-
dot const Balances.ExistentialDeposit --
|
|
394
|
+
dot const Balances.ExistentialDeposit --json | jq
|
|
355
395
|
```
|
|
356
396
|
|
|
357
397
|
### Inspect metadata
|
|
@@ -525,21 +565,21 @@ Decode a hex-encoded call into a YAML or JSON file that is compatible with [file
|
|
|
525
565
|
|
|
526
566
|
```bash
|
|
527
567
|
# Decode a raw hex call to YAML
|
|
528
|
-
dot tx.0x0001076465616462656566 --yaml
|
|
568
|
+
dot tx.0x0001076465616462656566 --to-yaml
|
|
529
569
|
|
|
530
570
|
# Decode a raw hex call to JSON
|
|
531
|
-
dot tx.0x0001076465616462656566 --json
|
|
571
|
+
dot tx.0x0001076465616462656566 --to-json
|
|
532
572
|
|
|
533
573
|
# Encode a named call and output as YAML
|
|
534
|
-
dot tx.System.remark 0xdeadbeef --yaml
|
|
574
|
+
dot tx.System.remark 0xdeadbeef --to-yaml
|
|
535
575
|
|
|
536
576
|
# Round-trip: encode to hex, decode to YAML, re-encode from file
|
|
537
|
-
dot tx.System.remark 0xdeadbeef --encode
|
|
538
|
-
dot tx.0x0001076465616462656566 --yaml > remark.yaml
|
|
539
|
-
dot ./remark.yaml --encode
|
|
577
|
+
dot tx.System.remark 0xdeadbeef --encode # 0x0001076465616462656566
|
|
578
|
+
dot tx.0x0001076465616462656566 --to-yaml > remark.yaml
|
|
579
|
+
dot ./remark.yaml --encode # same hex
|
|
540
580
|
```
|
|
541
581
|
|
|
542
|
-
`--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`.
|
|
543
583
|
|
|
544
584
|
Both dry-run and submission display the encoded call hex and a decoded human-readable form:
|
|
545
585
|
|
|
@@ -627,7 +667,7 @@ Override low-level transaction parameters. Useful for rapid-fire submission (cus
|
|
|
627
667
|
| `--nonce <n>` | non-negative integer | Override the auto-detected nonce |
|
|
628
668
|
| `--tip <amount>` | non-negative integer (planck) | Priority tip for the transaction pool |
|
|
629
669
|
| `--mortality <spec>` | `immortal` or period (min 4) | Transaction mortality window |
|
|
630
|
-
| `--at <block>` |
|
|
670
|
+
| `--at <block>` | 0x-prefixed block hash | Block hash to validate against (defaults to finalized) |
|
|
631
671
|
|
|
632
672
|
```bash
|
|
633
673
|
# Fire-and-forget: submit two txs in rapid succession with manual nonces
|
|
@@ -643,14 +683,14 @@ dot tx System.remark 0xdead --from alice --mortality immortal
|
|
|
643
683
|
# Set a custom mortality period (rounds up to nearest power of two)
|
|
644
684
|
dot tx System.remark 0xdead --from alice --mortality 128
|
|
645
685
|
|
|
646
|
-
# Validate against
|
|
647
|
-
dot tx System.remark 0xdead --from alice --at
|
|
686
|
+
# Validate against a specific block hash
|
|
687
|
+
dot tx System.remark 0xdead --from alice --at 0x1234...abcd
|
|
648
688
|
|
|
649
689
|
# Combine: rapid-fire with tip and broadcast-only
|
|
650
690
|
dot tx System.remark 0xdead --from alice --nonce 5 --tip 500000 --wait broadcast
|
|
651
691
|
```
|
|
652
692
|
|
|
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).
|
|
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).
|
|
654
694
|
|
|
655
695
|
### File-based commands
|
|
656
696
|
|
|
@@ -837,7 +877,7 @@ CALL=$(dot tx.System.remark 0xdead --encode)
|
|
|
837
877
|
dot ./xcm-transact.yaml --var CALL=$CALL --encode
|
|
838
878
|
```
|
|
839
879
|
|
|
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.
|
|
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.
|
|
841
881
|
|
|
842
882
|
### Compute hashes
|
|
843
883
|
|
|
@@ -857,7 +897,7 @@ dot hash keccak256 --file ./data.bin
|
|
|
857
897
|
echo -n "hello" | dot hash sha256 --stdin
|
|
858
898
|
|
|
859
899
|
# JSON output
|
|
860
|
-
dot hash blake2b256 0xdeadbeef --
|
|
900
|
+
dot hash blake2b256 0xdeadbeef --json
|
|
861
901
|
```
|
|
862
902
|
|
|
863
903
|
Run `dot hash` with no arguments to see all available algorithms.
|
|
@@ -880,7 +920,7 @@ dot sign --file ./payload.bin --from alice
|
|
|
880
920
|
echo -n "hello" | dot sign --stdin --from alice
|
|
881
921
|
|
|
882
922
|
# JSON output (for scripting)
|
|
883
|
-
dot sign "hello" --from alice --
|
|
923
|
+
dot sign "hello" --from alice --json
|
|
884
924
|
```
|
|
885
925
|
|
|
886
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...)`).
|
|
@@ -908,7 +948,7 @@ dot parachain 2004 --type sibling
|
|
|
908
948
|
dot parachain 1000 --prefix 0
|
|
909
949
|
|
|
910
950
|
# JSON output
|
|
911
|
-
dot parachain 1000 --
|
|
951
|
+
dot parachain 1000 --json
|
|
912
952
|
```
|
|
913
953
|
|
|
914
954
|
Run `dot parachain` with no arguments to see usage and examples.
|
|
@@ -928,7 +968,7 @@ dot verifiable alice --context candidate
|
|
|
928
968
|
dot verifiable alice --context pps
|
|
929
969
|
|
|
930
970
|
# JSON output (for scripting)
|
|
931
|
-
dot verifiable alice --context candidate --
|
|
971
|
+
dot verifiable alice --context candidate --json
|
|
932
972
|
```
|
|
933
973
|
|
|
934
974
|
The derivation flow:
|
|
@@ -982,18 +1022,46 @@ dot tx.System.remark 0xdead # shows call help (no error)
|
|
|
982
1022
|
| `--help` | Show help (global or command-specific) |
|
|
983
1023
|
| `--chain <name>` | Target chain (default from config) |
|
|
984
1024
|
| `--rpc <url>` | Override RPC endpoint(s) for this call (repeat for fallback) |
|
|
985
|
-
|
|
986
|
-
| `--
|
|
1025
|
+
|
|
1026
|
+
| `--json` | Structured JSON output (shorthand for `--output json`) |
|
|
1027
|
+
| `--output json` | Structured JSON output |
|
|
987
1028
|
| `--dump` | Dump all entries of a storage map (required for keyless map queries) |
|
|
988
1029
|
| `-w, --wait <level>` | Tx wait level: `broadcast`, `best-block` / `best`, `finalized` (default) |
|
|
989
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
|
+
|
|
990
1055
|
### Pipe-safe output
|
|
991
1056
|
|
|
992
|
-
All commands follow Unix conventions: **data goes to stdout, progress goes to stderr**. This means you can safely pipe `--
|
|
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:
|
|
993
1058
|
|
|
994
1059
|
```bash
|
|
995
|
-
dot const System.SS58Prefix --
|
|
996
|
-
dot query System.Number --
|
|
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'
|
|
997
1065
|
```
|
|
998
1066
|
|
|
999
1067
|
In an interactive terminal, both streams render together so you see progress and results normally.
|
|
@@ -1085,7 +1153,7 @@ Config and metadata caches live in `~/.polkadot/`:
|
|
|
1085
1153
|
|
|
1086
1154
|
## Environment compatibility
|
|
1087
1155
|
|
|
1088
|
-
The CLI works in Node.js, Bun, and sandboxed runtimes (e.g. LLM tool-use / MCP environments)
|
|
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.
|
|
1089
1157
|
|
|
1090
1158
|
## Development
|
|
1091
1159
|
|