polkadot-cli 1.13.0 → 1.14.1
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 +216 -13
- package/dist/cli.mjs +705 -113
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,13 +25,16 @@ Ships with Polkadot and all system parachains preconfigured with multiple fallba
|
|
|
25
25
|
- ✅ File-based commands — run any command from a YAML/JSON file with variable substitution
|
|
26
26
|
- ✅ Parachain sovereign accounts — derive child and sibling addresses from a parachain ID
|
|
27
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)
|
|
28
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
|
|
29
32
|
|
|
30
33
|
### Preconfigured chains
|
|
31
34
|
|
|
32
35
|
| Network | Chain |
|
|
33
36
|
|---------|-------|
|
|
34
|
-
| Polkadot | `polkadot` (relay
|
|
37
|
+
| Polkadot | `polkadot` (relay) |
|
|
35
38
|
| | `polkadot-asset-hub` |
|
|
36
39
|
| | `polkadot-bridge-hub` |
|
|
37
40
|
| | `polkadot-collectives` |
|
|
@@ -79,13 +82,9 @@ dot chain add my-para --rpc wss://rpc.example.com --relay polkadot --parachain-i
|
|
|
79
82
|
dot chain list
|
|
80
83
|
|
|
81
84
|
# Re-fetch metadata after a runtime upgrade
|
|
82
|
-
dot chain update # updates default chain
|
|
83
85
|
dot chain update kusama # updates a specific chain
|
|
84
86
|
dot chain update --all # updates all configured chains in parallel
|
|
85
87
|
|
|
86
|
-
# Set default chain
|
|
87
|
-
dot chain default kusama
|
|
88
|
-
|
|
89
88
|
# Remove a chain
|
|
90
89
|
dot chain remove westend
|
|
91
90
|
```
|
|
@@ -97,7 +96,7 @@ dot chain remove westend
|
|
|
97
96
|
```
|
|
98
97
|
Configured Chains
|
|
99
98
|
|
|
100
|
-
polkadot
|
|
99
|
+
polkadot wss://polkadot.ibp.network
|
|
101
100
|
├─ polkadot-asset-hub [1000] wss://...
|
|
102
101
|
├─ polkadot-bridge-hub [1002] wss://...
|
|
103
102
|
├─ polkadot-collectives [1001] wss://...
|
|
@@ -115,6 +114,55 @@ All built-in system parachains are preconfigured with their relay chain and para
|
|
|
115
114
|
|
|
116
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.
|
|
117
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
|
+
|
|
118
166
|
### Manage accounts
|
|
119
167
|
|
|
120
168
|
Dev accounts (Alice, Bob, Charlie, Dave, Eve, Ferdie) are always available for testnets. Create or import your own accounts for any chain.
|
|
@@ -158,6 +206,16 @@ MY_SECRET="word1 word2 ..." dot tx System.remark 0xdead --from ci-signer
|
|
|
158
206
|
dot account remove my-validator
|
|
159
207
|
dot account delete my-validator stale-key
|
|
160
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
|
+
|
|
161
219
|
# Inspect an account — show public key and SS58 address
|
|
162
220
|
dot account inspect alice
|
|
163
221
|
dot account alice # shorthand (same as inspect)
|
|
@@ -287,6 +345,38 @@ dot account derive treasury treasury-staking --path //staking
|
|
|
287
345
|
|
|
288
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`.
|
|
289
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
|
+
|
|
290
380
|
### Chain prefix
|
|
291
381
|
|
|
292
382
|
Instead of the `--chain` flag, you can prefix any target with the chain name using dot notation:
|
|
@@ -299,9 +389,9 @@ dot inspect kusama.System
|
|
|
299
389
|
dot inspect kusama.System.Account
|
|
300
390
|
```
|
|
301
391
|
|
|
302
|
-
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
|
|
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`.
|
|
303
393
|
|
|
304
|
-
|
|
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.
|
|
305
395
|
|
|
306
396
|
### Space-separated syntax
|
|
307
397
|
|
|
@@ -460,11 +550,66 @@ dot apis.Core.version --help
|
|
|
460
550
|
Runtime API info requires v15 metadata. If `dot apis` shows 0 APIs, update the cached metadata:
|
|
461
551
|
|
|
462
552
|
```bash
|
|
463
|
-
dot chain update # default chain
|
|
464
553
|
dot chain update people-paseo # specific chain
|
|
465
554
|
dot chain update --all # all configured chains
|
|
466
555
|
```
|
|
467
556
|
|
|
557
|
+
#### Argument formats
|
|
558
|
+
|
|
559
|
+
Runtime API arguments accept the same shorthand as `dot tx` arguments:
|
|
560
|
+
|
|
561
|
+
| Type | Pass as | Example |
|
|
562
|
+
|------|---------|---------|
|
|
563
|
+
| Integers (`u8` … `u32`, `i8` … `i32`) | decimal | `0`, `42` |
|
|
564
|
+
| Big integers (`u64`, `u128`, `u256`, `i64` …) | decimal | `1000000000000` |
|
|
565
|
+
| `bool` | `true` / `false` | `true` |
|
|
566
|
+
| `AccountId32` | dev name, stored account, SS58, or `0x` + 64 hex pubkey | `alice`, `5GrwvaEF…` |
|
|
567
|
+
| `Vec<u8>` (unsized bytes) | `0x…` hex or text | `0xdeadbeef`, `hello` |
|
|
568
|
+
| `[u8; N]` (sized bytes, e.g. `H160`/`H256`/raw `AccountId`) | `0x` + exactly `2 * N` hex chars (recommended), or text | `0x970951a12f975e6762482aca81e57d5a2a4e73f4` |
|
|
569
|
+
| `Option<T>` | `null` (recommended), `none`, `undefined` — or a `T` value for `Some(value)` | `null` |
|
|
570
|
+
| `Vec<T>` (non-byte) | JSON array or comma-separated | `[1,2,3]`, `1,2,3` |
|
|
571
|
+
| Structs / nested enums | JSON | `{"type":"X1","value":{…}}` |
|
|
572
|
+
|
|
573
|
+
For sized byte arrays (`[u8; N]`) — common for Ethereum-style addresses (`H160`, `[u8; 20]`), 32-byte hashes (`H256`), and raw `AccountId32` bytes — pass a `0x`-prefixed hex string. Example: a contract call against the `pallet-revive` runtime API:
|
|
574
|
+
|
|
575
|
+
```bash
|
|
576
|
+
ALICE=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
|
|
577
|
+
CONTRACT=0x970951a12f975e6762482aca81e57d5a2a4e73f4 # H160, [u8; 20]
|
|
578
|
+
CALLDATA=$(cast calldata "set(uint256)" 42)
|
|
579
|
+
|
|
580
|
+
dot --chain paseo-asset-hub apis.ReviveApi.call \
|
|
581
|
+
"$ALICE" "$CONTRACT" 0 null null "$CALLDATA"
|
|
582
|
+
# ^ origin ^ dest ^ value ^ gas_limit (Option, none) ^ deposit (Option, none) ^ input_data (Vec<u8>)
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
##### Passing `Option<T>`
|
|
586
|
+
|
|
587
|
+
Absent options (`None`) can be written three ways, all equivalent:
|
|
588
|
+
|
|
589
|
+
```bash
|
|
590
|
+
dot apis.ReviveApi.call "$ALICE" "$CONTRACT" 0 null null "$CALLDATA"
|
|
591
|
+
dot apis.ReviveApi.call "$ALICE" "$CONTRACT" 0 none none "$CALLDATA"
|
|
592
|
+
dot apis.ReviveApi.call "$ALICE" "$CONTRACT" 0 undefined undefined "$CALLDATA"
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
`null` is the **recommended** form — it matches JSON / YAML semantics, so args read identically on the CLI and inside [file-based command](#file-based-commands) YAML/JSON inputs.
|
|
596
|
+
|
|
597
|
+
A present option (`Some(value)`) is just the value itself — no wrapping:
|
|
598
|
+
|
|
599
|
+
```bash
|
|
600
|
+
# gas_limit = Some({ ref_time: 1_000_000, proof_size: 100_000 })
|
|
601
|
+
dot apis.ReviveApi.call "$ALICE" "$CONTRACT" 0 \
|
|
602
|
+
'{"ref_time":1000000,"proof_size":100000}' \
|
|
603
|
+
null \
|
|
604
|
+
"$CALLDATA"
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
Notes:
|
|
608
|
+
- The `null` / `none` / `undefined` literals are case-sensitive (lowercase only).
|
|
609
|
+
- There is no `Some(value)` prefix — bare values are already treated as `Some`.
|
|
610
|
+
|
|
611
|
+
Use `dot apis.<ApiName>.<method> --help` to see the exact argument signature for any method.
|
|
612
|
+
|
|
468
613
|
### Focused commands
|
|
469
614
|
|
|
470
615
|
Browse specific metadata categories directly without using `dot inspect`:
|
|
@@ -692,6 +837,64 @@ dot tx System.remark 0xdead --from alice --nonce 5 --tip 500000 --wait broadcast
|
|
|
692
837
|
|
|
693
838
|
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).
|
|
694
839
|
|
|
840
|
+
#### Pay fees in an alternative asset
|
|
841
|
+
|
|
842
|
+
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.
|
|
843
|
+
|
|
844
|
+
```bash
|
|
845
|
+
# Pay fees in USDT (asset id 1337, PalletInstance 50) on Polkadot Asset Hub
|
|
846
|
+
dot tx Balances.transfer_keep_alive 5FHneW46... 1000000000000 \
|
|
847
|
+
--from alice --chain polkadot-asset-hub \
|
|
848
|
+
--asset '{"parents":0,"interior":{"type":"X2","value":[{"type":"PalletInstance","value":50},{"type":"GeneralIndex","value":"1337"}]}}'
|
|
849
|
+
|
|
850
|
+
# Dry-run to see the native-denominated fee estimate
|
|
851
|
+
dot tx Balances.transfer_keep_alive 5FHneW46... 1000000000000 \
|
|
852
|
+
--from alice --chain polkadot-asset-hub --dry-run \
|
|
853
|
+
--asset '{"parents":0,"interior":{"type":"X2","value":[{"type":"PalletInstance","value":50},{"type":"GeneralIndex","value":"1337"}]}}'
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
The `--asset` echo is included in dry-run and submission output (and `--json`). A few things to know:
|
|
857
|
+
|
|
858
|
+
- 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.
|
|
859
|
+
- The estimated fee shown is **native-denominated**. The on-chain asset-conversion pool determines the actual asset amount charged at execution time.
|
|
860
|
+
- `--asset` is unnecessary (and not compatible) with `--unsigned`: unsigned transactions default `ChargeAssetTxPayment` to zero tip / no asset.
|
|
861
|
+
- Combine freely with `--tip`, `--nonce`, `--mortality`, and `--at`. `--tip` is encoded inside the asset-payment extension alongside the asset id.
|
|
862
|
+
|
|
863
|
+
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.
|
|
864
|
+
|
|
865
|
+
#### Unsigned/authorized transactions
|
|
866
|
+
|
|
867
|
+
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.
|
|
868
|
+
|
|
869
|
+
```bash
|
|
870
|
+
# Submit an authorized call on the People chain
|
|
871
|
+
dot tx People.create_people_collection --unsigned --chain people
|
|
872
|
+
|
|
873
|
+
# Dry-run to inspect before submitting
|
|
874
|
+
dot tx People.create_people_collection --unsigned --chain people --dry-run
|
|
875
|
+
|
|
876
|
+
# Encode the full general transaction bytes
|
|
877
|
+
dot tx People.create_people_collection --unsigned --chain people --encode
|
|
878
|
+
|
|
879
|
+
# With raw hex call data
|
|
880
|
+
dot tx 0x3306 --unsigned --chain people
|
|
881
|
+
|
|
882
|
+
# JSON output for scripting
|
|
883
|
+
dot tx People.create_people_collection --unsigned --chain people --json
|
|
884
|
+
```
|
|
885
|
+
|
|
886
|
+
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.
|
|
887
|
+
|
|
888
|
+
`--unsigned` is mutually exclusive with `--from`, `--nonce`, `--tip`, and `--mortality`. File-based input supports `unsigned: true`:
|
|
889
|
+
|
|
890
|
+
```yaml
|
|
891
|
+
chain: people
|
|
892
|
+
unsigned: true
|
|
893
|
+
tx:
|
|
894
|
+
People:
|
|
895
|
+
create_people_collection: null
|
|
896
|
+
```
|
|
897
|
+
|
|
695
898
|
### File-based commands
|
|
696
899
|
|
|
697
900
|
Run any `dot` command from a YAML or JSON file. Especially useful for complex calls like XCM messages that are hard to construct inline.
|
|
@@ -1020,8 +1223,8 @@ dot tx.System.remark 0xdead # shows call help (no error)
|
|
|
1020
1223
|
| Flag | Description |
|
|
1021
1224
|
|------|-------------|
|
|
1022
1225
|
| `--help` | Show help (global or command-specific) |
|
|
1023
|
-
| `--chain <name>` | Target chain (
|
|
1024
|
-
| `--rpc <url>` | Override RPC endpoint(s) for this call (repeat for fallback) |
|
|
1226
|
+
| `--chain <name>` | Target chain (required unless a dotpath chain prefix is used) |
|
|
1227
|
+
| `--rpc <url>` | Override RPC endpoint(s) for this call (repeat for fallback). Always fetches fresh metadata, bypassing the cache |
|
|
1025
1228
|
|
|
1026
1229
|
| `--json` | Structured JSON output (shorthand for `--output json`) |
|
|
1027
1230
|
| `--output json` | Structured JSON output |
|
|
@@ -1092,7 +1295,7 @@ dot apis.Core.<Tab> # → apis.Core.version, ...
|
|
|
1092
1295
|
dot polkadot.<Tab> # → polkadot.query, polkadot.tx, ..., polkadot.apis
|
|
1093
1296
|
dot --chain <Tab> # → polkadot, paseo, ...
|
|
1094
1297
|
dot --from <Tab> # → alice, bob, ..., stored account names
|
|
1095
|
-
dot chain <Tab> # → add, remove, update, list
|
|
1298
|
+
dot chain <Tab> # → add, remove, update, list
|
|
1096
1299
|
```
|
|
1097
1300
|
|
|
1098
1301
|
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.
|
|
@@ -1141,7 +1344,7 @@ Config and metadata caches live in `~/.polkadot/`:
|
|
|
1141
1344
|
|
|
1142
1345
|
```
|
|
1143
1346
|
~/.polkadot/
|
|
1144
|
-
├── config.json # chains
|
|
1347
|
+
├── config.json # configured chains
|
|
1145
1348
|
├── accounts.json # stored accounts (⚠️ secrets are NOT encrypted — see below)
|
|
1146
1349
|
├── update-check.json # cached update check result
|
|
1147
1350
|
└── chains/
|