polkadot-cli 1.17.0 → 1.19.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 +276 -40
- package/dist/cli.mjs +1472 -115
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -20,12 +20,13 @@ Ships with Polkadot and all system parachains preconfigured with multiple fallba
|
|
|
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 polkadot.apis.Core.version`
|
|
23
|
+
- ✅ Raw JSON-RPC calls — `dot polkadot.rpc.system_health`, with discovery via `rpc_methods` and tab-completion
|
|
23
24
|
- ✅ Full-metadata dump — `dot metadata <chain>` emits one JSON blob with pallets, runtime APIs, and transaction extensions (or raw SCALE bytes via `--raw`)
|
|
24
25
|
- ✅ Stale-metadata detection — when a tx or query fails because the runtime upgraded, the CLI tells you exactly which `dot chain update` to run
|
|
25
26
|
- ✅ Chain topology — relay/parachain hierarchy with tree display and auto-detection
|
|
26
27
|
- ✅ Batteries included — all system parachains and testnets already setup to be used
|
|
27
28
|
- ✅ File-based commands — run any command from a YAML/JSON file with variable substitution
|
|
28
|
-
- ✅
|
|
29
|
+
- ✅ Sovereign accounts — store a parachain (child / sibling) or pallet (Treasury, Bounties, NominationPools, …) sovereign as a named watch-only account in one command
|
|
29
30
|
- ✅ Message signing — sign arbitrary bytes with account keypairs for use as `MultiSignature` arguments
|
|
30
31
|
- ✅ Unsigned/authorized transactions — submit governance-authorized calls without a signer (`--unsigned`)
|
|
31
32
|
- ✅ Non-native fee payment — pay tx fees in any asset the chain accepts via `--asset` (asset-hub-style chains)
|
|
@@ -323,7 +324,7 @@ dot account add treasury 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
|
|
|
323
324
|
dot account add council 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
|
|
324
325
|
```
|
|
325
326
|
|
|
326
|
-
Watch-only accounts appear in `dot account list`
|
|
327
|
+
Watch-only accounts appear in `dot account list` under a dedicated **Watch-only** section and can be inspected and removed like any other account. They cannot be used with `--from` (signing) or as a source for `derive`.
|
|
327
328
|
|
|
328
329
|
The `add` subcommand is context-sensitive: bare `add <name> <address>` creates a watch-only entry, while `add --secret` or `add --env` imports a keyed account. `dot account import` is reserved for file-based batch import.
|
|
329
330
|
|
|
@@ -363,6 +364,8 @@ Convert between SS58 addresses, hex public keys, and account names. Accepts any
|
|
|
363
364
|
- **Stored account name** — looks up the public key from the accounts file
|
|
364
365
|
- **SS58 address** — decodes to the underlying public key
|
|
365
366
|
- **Hex public key** (`0x` + 64 hex chars) — encodes to SS58
|
|
367
|
+
- **`--pallet-id <id>`** — derives a pallet sovereign address without saving it (script-friendly; nothing persists)
|
|
368
|
+
- **`--parachain <id> --parachain-type <child|sibling>`** — derives a parachain sovereign address without saving it
|
|
366
369
|
|
|
367
370
|
```bash
|
|
368
371
|
dot account inspect alice
|
|
@@ -370,6 +373,11 @@ dot account alice # shorthand — unknown subcommands fall th
|
|
|
370
373
|
|
|
371
374
|
dot account inspect 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
|
|
372
375
|
dot account inspect 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
|
|
376
|
+
|
|
377
|
+
# pallet-revive H160 — the 20-byte address shape from EVM tooling. Same
|
|
378
|
+
# input slot as SS58 / hex pubkey; resolved to the deterministic fallback
|
|
379
|
+
# AccountId32 (`H160 || 0xEE * 12`).
|
|
380
|
+
dot account inspect 0x9621DDe636dE098B43Efb0fA9b61fAcFE328F99D
|
|
373
381
|
```
|
|
374
382
|
|
|
375
383
|
Use `--prefix` to encode the SS58 address with a specific network prefix (default: 42):
|
|
@@ -387,8 +395,10 @@ dot account inspect alice --json
|
|
|
387
395
|
# {
|
|
388
396
|
# "publicKey": "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d",
|
|
389
397
|
# "ss58": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
|
|
398
|
+
# "h160": "0x9621DDe636dE098B43Efb0fA9b61fAcFE328F99D",
|
|
390
399
|
# "prefix": 42,
|
|
391
|
-
# "name": "Alice"
|
|
400
|
+
# "name": "Alice",
|
|
401
|
+
# "kind": "dev"
|
|
392
402
|
# }
|
|
393
403
|
```
|
|
394
404
|
|
|
@@ -400,11 +410,80 @@ dot account inspect alice
|
|
|
400
410
|
# Account Info
|
|
401
411
|
#
|
|
402
412
|
# Name: Alice
|
|
413
|
+
# Kind: dev
|
|
403
414
|
# Public Key: 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
|
|
404
415
|
# SS58: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
|
|
416
|
+
# H160: 0x9621DDe636dE098B43Efb0fA9b61fAcFE328F99D
|
|
417
|
+
# Prefix: 42
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
The `Kind:` line categorises the account: `dev` (built-in), `signer` (has a secret/env), `watch-only` (raw external address), `pallet sovereign` (derived from a `PalletId`), `parachain sovereign (child|sibling)` (derived from a parachain ID), or `revive H160 fallback` (a 20-byte input resolved to its deterministic Substrate AccountId32). For derived sovereigns, an extra `Source:` line shows what the address was derived from. For env-backed signers, an `Env:` line shows the variable; for derived child keys, `Derivation:` shows the path.
|
|
421
|
+
|
|
422
|
+
##### pallet-revive H160 address
|
|
423
|
+
|
|
424
|
+
Every Substrate account has a corresponding 20-byte H160 address under [pallet-revive](https://github.com/paritytech/polkadot-sdk/tree/master/substrate/frame/revive) (the new EVM-compatible smart-contracts pallet on Polkadot Hub / Asset Hub). `dot account inspect` always shows it, EIP-55 checksummed, on the `H160:` line. The mapping is offline and prefix-independent:
|
|
425
|
+
|
|
426
|
+
- **AccountId32 → H160:** if the last 12 bytes are `0xEE`, strip them (the account originated from an Eth address); otherwise `keccak256(accountId32)` and take the last 20 bytes.
|
|
427
|
+
- **H160 → AccountId32:** deterministic fallback is `H160 || 0xEE * 12`. (The full mapping after a successful `pallet_revive.map_account` extrinsic lives in on-chain `AddressSuffix` storage and isn't recoverable offline — that's a chain-state lookup.)
|
|
428
|
+
|
|
429
|
+
Pass a 20-byte hex value as the inspect input to resolve it back to its fallback Substrate account:
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
dot account inspect 0x9621DDe636dE098B43Efb0fA9b61fAcFE328F99D
|
|
433
|
+
# Output:
|
|
434
|
+
# Account Info
|
|
435
|
+
#
|
|
436
|
+
# Kind: revive H160 fallback
|
|
437
|
+
# Public Key: 0x9621dde636de098b43efb0fa9b61facfe328f99deeeeeeeeeeeeeeeeeeeeeeee
|
|
438
|
+
# SS58: 5FTZ6n1wY3GBqEZ2DWEdspbTarvRnp8DM8x2YXbWubu7JN98
|
|
439
|
+
# H160: 0x9621DDe636dE098B43Efb0fA9b61fAcFE328F99D
|
|
405
440
|
# Prefix: 42
|
|
441
|
+
|
|
442
|
+
# Script-friendly: just the H160 for a given account
|
|
443
|
+
dot account inspect alice --json | jq -r .h160
|
|
444
|
+
# 0x9621DDe636dE098B43Efb0fA9b61fAcFE328F99D
|
|
406
445
|
```
|
|
407
446
|
|
|
447
|
+
Note: `dot` implements the current `pallet-revive` master variant (keccak fallback). Older `stable2412` runtimes used plain `accountId32[..20]` truncation; if you target one, compute it manually until a `--revive-truncate` flag lands.
|
|
448
|
+
|
|
449
|
+
##### Stateless sovereign derivation (script-friendly)
|
|
450
|
+
|
|
451
|
+
Pass `--pallet-id` or `--parachain` / `--parachain-type` to compute a sovereign address **without persisting** anything to `~/.polkadot/accounts.json`. The output shape matches the stored case (same `Kind:` / `Source:` / SS58 / public key + same `--json` schema), but no `Name:` line and nothing in `dot account list` afterwards. Use this in scripts when you just need the address:
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
# Polkadot Treasury — pallet sovereign on prefix 0
|
|
455
|
+
dot account inspect --pallet-id py/trsry --prefix 0
|
|
456
|
+
# Output:
|
|
457
|
+
# Account Info
|
|
458
|
+
#
|
|
459
|
+
# Kind: pallet sovereign
|
|
460
|
+
# Public Key: 0x6d6f646c70792f74727372790000000000000000000000000000000000000000
|
|
461
|
+
# SS58: 13UVJyLnbVp9RBZYFwFGyDvVd1y27Tt8tkntv6Q7JVPhFsTB
|
|
462
|
+
# Source: PalletId py/trsry (0x70792f7472737279)
|
|
463
|
+
# Prefix: 0
|
|
464
|
+
|
|
465
|
+
# Hex form works the same
|
|
466
|
+
dot account inspect --pallet-id 0x70792f7472737279 --prefix 0
|
|
467
|
+
|
|
468
|
+
# Parachain sovereigns (type is required — child = on relay, sibling = on another parachain)
|
|
469
|
+
dot account inspect --parachain 1004 --parachain-type child
|
|
470
|
+
|
|
471
|
+
# Pipeline: just the SS58
|
|
472
|
+
SS58=$(dot account inspect --pallet-id py/trsry --prefix 0 --json | jq -r .ss58)
|
|
473
|
+
|
|
474
|
+
# JSON shape includes a `source` object describing the derivation
|
|
475
|
+
dot account inspect --pallet-id py/trsry --json
|
|
476
|
+
# {
|
|
477
|
+
# "publicKey": "0x6d6f646c70792f74727372790000000000000000000000000000000000000000",
|
|
478
|
+
# "ss58": "5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z",
|
|
479
|
+
# "prefix": 42,
|
|
480
|
+
# "kind": "pallet sovereign",
|
|
481
|
+
# "source": { "kind": "pallet", "palletId": "py/trsry", "palletIdHex": "0x70792f7472737279" }
|
|
482
|
+
# }
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Constraints (will error): cannot combine a positional input with derivation flags; `--pallet-id` and `--parachain` are mutually exclusive; `--parachain` requires `--parachain-type child|sibling`; `--show-secret` doesn't apply (derived sovereigns have no key).
|
|
486
|
+
|
|
408
487
|
#### Reveal the sr25519 private key
|
|
409
488
|
|
|
410
489
|
For provisioning another signer (e.g. a server that expects a raw hex private key in an env var), add `--show-secret` to print the **64-byte sr25519 expanded secret** as `0x`-prefixed hex:
|
|
@@ -426,7 +505,7 @@ dot account add ci-signer --env MY_SECRET
|
|
|
426
505
|
|
|
427
506
|
`--secret` and `--env` are mutually exclusive. Use `dot account add` for single-account imports; `dot account import` is reserved for file-based batch import.
|
|
428
507
|
|
|
429
|
-
The secret is never written to disk. At signing time, the CLI reads `$MY_SECRET` and derives the keypair. If the variable is not set, the CLI errors with a clear message. `account list`
|
|
508
|
+
The secret is never written to disk. At signing time, the CLI reads `$MY_SECRET` and derives the keypair. If the variable is not set, the CLI errors with a clear message. `account list` annotates env-backed signers with `env $MY_SECRET` in the metadata column and resolves the address live when the variable is available.
|
|
430
509
|
|
|
431
510
|
#### Derivation paths
|
|
432
511
|
|
|
@@ -448,11 +527,15 @@ dot account derive treasury treasury-staking --path //staking
|
|
|
448
527
|
|
|
449
528
|
`derive` copies the source account's secret and applies the given path. It requires both a source name, a new name, and `--path`. Works with env-backed accounts too — the derived account shares the same env var reference.
|
|
450
529
|
|
|
451
|
-
`account list` shows
|
|
530
|
+
`account list` shows derivation paths and env sources on tree-style continuation lines (label names mirror the `--flag` that sets them):
|
|
452
531
|
|
|
453
532
|
```
|
|
454
|
-
|
|
455
|
-
|
|
533
|
+
Signers
|
|
534
|
+
treasury-staking 5FHneW46...
|
|
535
|
+
└─ path: //staking
|
|
536
|
+
ci-signer 5EPCUjPx...
|
|
537
|
+
├─ path: //ci
|
|
538
|
+
└─ env: $MY_SECRET
|
|
456
539
|
```
|
|
457
540
|
|
|
458
541
|
**Supported secret formats for import:**
|
|
@@ -532,7 +615,7 @@ dot polkadot.apis.Core
|
|
|
532
615
|
dot apis Core --chain polkadot
|
|
533
616
|
```
|
|
534
617
|
|
|
535
|
-
This works for all categories (`query`, `tx`, `const`, `events`, `errors`, `apis`, `extensions`). When passing positional method arguments, keep `Pallet` and `Item` either fully dot-joined (`query.System.Account 5Grw...`) or fully space-separated (`query System Account 5Grw...`) — mixing the two (`query System.Account 5Grw...`) does not work because the second arg gets parsed as a pallet name.
|
|
618
|
+
This works for all categories (`query`, `tx`, `const`, `events`, `errors`, `apis`, `extensions`, `rpc`). When passing positional method arguments, keep `Pallet` and `Item` either fully dot-joined (`query.System.Account 5Grw...`) or fully space-separated (`query System Account 5Grw...`) — mixing the two (`query System.Account 5Grw...`) does not work because the second arg gets parsed as a pallet name.
|
|
536
619
|
|
|
537
620
|
### Query storage
|
|
538
621
|
|
|
@@ -610,6 +693,40 @@ dot polkadot-asset-hub.query.Assets.Metadata 1984
|
|
|
610
693
|
# }
|
|
611
694
|
```
|
|
612
695
|
|
|
696
|
+
#### Historical reads — `--at <block>`
|
|
697
|
+
|
|
698
|
+
Storage queries default to the latest finalized head. Pass `--at` to read
|
|
699
|
+
state at a specific block hash, the chain head (`best`), or `finalized`
|
|
700
|
+
(explicit). Accepted on both `query.*` and `apis.*` runtime calls.
|
|
701
|
+
|
|
702
|
+
```bash
|
|
703
|
+
# Read at the current best (non-finalized) head — useful for low-latency reads
|
|
704
|
+
dot polkadot.query.System.Number --at best
|
|
705
|
+
|
|
706
|
+
# Read at the last finalized block — same as the default, but explicit
|
|
707
|
+
dot polkadot.query.System.Number --at finalized
|
|
708
|
+
|
|
709
|
+
# Pin a finalized hash and read multiple items at that exact block
|
|
710
|
+
HASH=$(dot polkadot.rpc.chain_getFinalizedHead | tr -d '"')
|
|
711
|
+
dot polkadot.query.System.Number --at "$HASH"
|
|
712
|
+
dot polkadot.apis.Core.version --at "$HASH" --json | jq .spec_version
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
`--at` accepts a 32-byte `0x…` block hash, `"best"`, or `"finalized"`.
|
|
716
|
+
Anything else errors before any network call. Tx submission rejects `"best"`.
|
|
717
|
+
|
|
718
|
+
> **Archive-only blocks**: papi v2 talks to the `chainHead_v1_*` JSON-RPC API,
|
|
719
|
+
> which only serves *pinned* (recent) blocks. Querying a hash older than a
|
|
720
|
+
> few minutes against a non-archive node fails with a clean error that
|
|
721
|
+
> includes a copy-pasteable `--rpc wss://<archive-endpoint>` hint:
|
|
722
|
+
>
|
|
723
|
+
> ```
|
|
724
|
+
> ⚠ 0x… is not available on the current RPC endpoint.
|
|
725
|
+
> Public nodes serve only recent (pinned) blocks via chainHead_v1_*.
|
|
726
|
+
> For deep historical reads, point --rpc at an archive endpoint, e.g.:
|
|
727
|
+
> dot ... --at 0x… --rpc wss://<archive-endpoint>
|
|
728
|
+
> ```
|
|
729
|
+
|
|
613
730
|
### Look up constants
|
|
614
731
|
|
|
615
732
|
```bash
|
|
@@ -963,6 +1080,74 @@ The list view tags each entry:
|
|
|
963
1080
|
|
|
964
1081
|
The detail view shows the extension's value type, its `additionalSigned` type, and a ready-to-adapt `--ext` snippet for custom extensions. Use this to discover what `--ext` payload a chain expects before submitting a `dot tx` command.
|
|
965
1082
|
|
|
1083
|
+
### Raw JSON-RPC
|
|
1084
|
+
|
|
1085
|
+
Substrate nodes expose a JSON-RPC surface that lives outside runtime metadata: `system_*` (sync state, peers, version), `chain_*` (blocks, headers, finalized head), `state_*` (raw storage, key iteration, runtime version), `author_*` (mempool, key management), `payment_*` (fee estimation), consensus families (`babe_*`, `grandpa_*`, `mmr_*`, `beefy_*`), and the new spec families (`chainSpec_v1_*`, `archive_v1_*`, `rpc_methods`). The `rpc` category exposes them all.
|
|
1086
|
+
|
|
1087
|
+
Methods are discovered per-chain via the standard `rpc_methods` JSON-RPC call and cached at `~/.polkadot/chains/<chain>/rpc-methods.json`. The set of available methods depends on the node, not the chain — an archive node adds `archive_v1_*`, validators may add `babe_epochAuthorship`, dev nodes add `dev_newBlock`, and `--rpc-methods safe` strips writes.
|
|
1088
|
+
|
|
1089
|
+
```bash
|
|
1090
|
+
# List all methods the node exposes, grouped by family
|
|
1091
|
+
dot polkadot.rpc
|
|
1092
|
+
# Output:
|
|
1093
|
+
# RPC methods on polkadot (129)
|
|
1094
|
+
#
|
|
1095
|
+
# system (20)
|
|
1096
|
+
# system_health Node sync state (peers, isSyncing, shouldHavePeers).
|
|
1097
|
+
# system_version Node software version string.
|
|
1098
|
+
# system_chain Chain name as reported by the node.
|
|
1099
|
+
# ...
|
|
1100
|
+
# chain (19)
|
|
1101
|
+
# chain_getBlock Full block (header + extrinsics) by hash.
|
|
1102
|
+
# chain_getFinalizedHead Hash of the latest finalized head.
|
|
1103
|
+
# ...
|
|
1104
|
+
|
|
1105
|
+
# Call a method
|
|
1106
|
+
dot polkadot.rpc.system_health
|
|
1107
|
+
# Output:
|
|
1108
|
+
# {
|
|
1109
|
+
# "peers": 131,
|
|
1110
|
+
# "isSyncing": false,
|
|
1111
|
+
# "shouldHavePeers": true
|
|
1112
|
+
# }
|
|
1113
|
+
|
|
1114
|
+
# Positional args (parsed by the same heuristic as tx args)
|
|
1115
|
+
dot polkadot.rpc.chain_getBlockHash 1000
|
|
1116
|
+
# Output:
|
|
1117
|
+
# "0xcf36a1e4a16fc579136137b8388f35490f09c5bdd7b9133835eba907a8b76c30"
|
|
1118
|
+
|
|
1119
|
+
# Show curated info for a known method
|
|
1120
|
+
dot polkadot.rpc.author_insertKey --help
|
|
1121
|
+
# Output:
|
|
1122
|
+
# author_insertKey
|
|
1123
|
+
# ⚠️ WRITE / state-changing
|
|
1124
|
+
# Insert a key into the node keystore.
|
|
1125
|
+
#
|
|
1126
|
+
# Family: author
|
|
1127
|
+
# Args: <keyType: string> <suri: string> <publicKey: hex>
|
|
1128
|
+
|
|
1129
|
+
# Refresh the cached method list (after a node upgrade)
|
|
1130
|
+
dot polkadot.rpc --refresh
|
|
1131
|
+
|
|
1132
|
+
# JSON output works on any method
|
|
1133
|
+
dot polkadot.rpc.system_health --json
|
|
1134
|
+
```
|
|
1135
|
+
|
|
1136
|
+
`dot chain add` and `dot chain update` automatically populate the method cache, and `dot chain info <name>` shows a per-family breakdown. Tab completion sources from the cache, so methods on a custom chain start completing the moment you've added or updated it.
|
|
1137
|
+
|
|
1138
|
+
About 50 well-known methods carry curated metadata (description, named args, `⚠️ WRITE` tag for state-changing calls). Any other method the node reports is callable via raw passthrough — args are forwarded as-is to the JSON-RPC `params` array.
|
|
1139
|
+
|
|
1140
|
+
Subscription methods (`*_subscribe*`, `chainHead_v1_follow`, `transaction_v1_*`) appear in tab-completion but error out as one-shots — they need a long-running follow session that doesn't fit a single CLI invocation:
|
|
1141
|
+
|
|
1142
|
+
```bash
|
|
1143
|
+
dot polkadot.rpc.chain_subscribeAllHeads
|
|
1144
|
+
# Error: "chain_subscribeAllHeads" is a subscription method (requires a follow
|
|
1145
|
+
# session) and is not callable as a one-shot. Use a long-running client for
|
|
1146
|
+
# streaming RPC.
|
|
1147
|
+
```
|
|
1148
|
+
|
|
1149
|
+
The `rpc` category is **flat** — there's no pallet level. The form is `[chain.]rpc.<method_name>`, where `<method_name>` keeps its underscores in a single segment (e.g. `polkadot.rpc.chain_getBlock`).
|
|
1150
|
+
|
|
966
1151
|
### Submit extrinsics
|
|
967
1152
|
|
|
968
1153
|
Build, sign, and submit transactions. Pass a `Pallet.Call` with arguments, or a raw SCALE-encoded call hex (e.g. from a multisig proposal or governance). Both forms display a decoded human-readable representation of the call.
|
|
@@ -1223,7 +1408,7 @@ Override low-level transaction parameters. Useful for rapid-fire submission (cus
|
|
|
1223
1408
|
| `--nonce <n>` | non-negative integer | Override the auto-detected nonce |
|
|
1224
1409
|
| `--tip <amount>` | non-negative integer (planck) | Priority tip for the transaction pool |
|
|
1225
1410
|
| `--mortality <spec>` | `immortal` or period (min 4) | Transaction mortality window |
|
|
1226
|
-
| `--at <block>` | 0x-prefixed block hash | Block
|
|
1411
|
+
| `--at <block>` | 0x-prefixed block hash, `"best"`, or `"finalized"` | Block to read/validate against (defaults to finalized). Also honored on `query.*` and `apis.*` for historical reads; tx submission rejects `"best"`. |
|
|
1227
1412
|
|
|
1228
1413
|
```bash
|
|
1229
1414
|
# Fire-and-forget: submit two txs in rapid succession with manual nonces
|
|
@@ -1509,7 +1694,7 @@ All existing flags work with file input — `--chain` overrides the file's `chai
|
|
|
1509
1694
|
|
|
1510
1695
|
### Compute hashes
|
|
1511
1696
|
|
|
1512
|
-
Compute cryptographic hashes commonly used in Substrate. Supports BLAKE2b-256, BLAKE2b-128, Keccak-256, and
|
|
1697
|
+
Compute cryptographic hashes commonly used in Substrate. Supports BLAKE2b-256, BLAKE2b-128, Keccak-256, SHA-256, and the XXH64-based `twox64` / `twox128` / `twox256` family used to build Substrate storage keys.
|
|
1513
1698
|
|
|
1514
1699
|
```bash
|
|
1515
1700
|
# Hash hex-encoded data
|
|
@@ -1538,6 +1723,16 @@ dot hash blake2b256 0xdeadbeef --json
|
|
|
1538
1723
|
# "input": "0xdeadbeef",
|
|
1539
1724
|
# "hash": "0xf3e925002fed7cc0ded46842569eb5c90c910c091d8d04a1bdf96e0db719fd91"
|
|
1540
1725
|
# }
|
|
1726
|
+
|
|
1727
|
+
# Substrate twox128 — pallet/storage prefix used everywhere in Substrate state
|
|
1728
|
+
dot hash twox128 System
|
|
1729
|
+
# Output:
|
|
1730
|
+
# 0x26aa394eea5630e07c48ae0c9558cef7
|
|
1731
|
+
|
|
1732
|
+
# Build a full storage key for `System.Number` and read it raw via JSON-RPC
|
|
1733
|
+
PALLET=$(dot hash twox128 System)
|
|
1734
|
+
ITEM=$(dot hash twox128 Number)
|
|
1735
|
+
dot polkadot.rpc.state_getStorage "${PALLET}${ITEM:2}"
|
|
1541
1736
|
```
|
|
1542
1737
|
|
|
1543
1738
|
Run `dot hash` with no arguments to see all available algorithms.
|
|
@@ -1579,50 +1774,91 @@ Output shows the crypto type, message bytes in hex, raw signature, and an `Enum`
|
|
|
1579
1774
|
|
|
1580
1775
|
Use `--type` to select the signature algorithm (default: `sr25519`). Run `dot sign` with no arguments to see usage and examples.
|
|
1581
1776
|
|
|
1582
|
-
###
|
|
1777
|
+
### Sovereign accounts (parachain & pallet)
|
|
1778
|
+
|
|
1779
|
+
`dot account add` accepts derivation flags that compute a deterministic sovereign address and store it as a named watch-only account — reusable in `--from` (for `--unsigned` flows), as a tx argument, and in `dot account list`. Runs offline; no chain connection required.
|
|
1583
1780
|
|
|
1584
|
-
|
|
1781
|
+
Two kinds of sovereign:
|
|
1585
1782
|
|
|
1586
|
-
- **
|
|
1587
|
-
- **
|
|
1783
|
+
- **Pallet sovereign** — every FRAME pallet that holds funds (Treasury, Bounties, Crowdloan, Society, NominationPools, ChildBounties, …) declares an 8-byte `PalletId`. The 32-byte account ID is `b"modl"` (4 bytes) + `palletId` (8 bytes) + 20 zero bytes. (`AccountIdConversion::into_account_truncating` with `PalletId::TYPE_ID = b"modl"` from `frame_support`.)
|
|
1784
|
+
- **Parachain sovereign** — every parachain has a `child` account (its account on the relay chain, `b"para"` prefix) and a `sibling` account (its account on another parachain, `b"sibl"` prefix). Both are 32-byte IDs of the form `prefix (4 bytes)` + `paraId as LE u32 (4 bytes)` + 24 zero bytes.
|
|
1588
1785
|
|
|
1589
1786
|
```bash
|
|
1590
|
-
#
|
|
1591
|
-
dot
|
|
1787
|
+
# Pallet sovereign — ASCII PalletId
|
|
1788
|
+
dot account add Treasury --pallet-id py/trsry
|
|
1592
1789
|
# Output:
|
|
1593
|
-
#
|
|
1790
|
+
# Account Added (watch-only)
|
|
1594
1791
|
#
|
|
1595
|
-
#
|
|
1596
|
-
#
|
|
1597
|
-
#
|
|
1598
|
-
# Prefix: 42
|
|
1599
|
-
#
|
|
1600
|
-
# Sibling:
|
|
1601
|
-
# Public Key: 0x7369626ce8030000000000000000000000000000000000000000000000000000
|
|
1602
|
-
# SS58: 5Eg2fntNprdN3FgH4sfEaaZhYtddZQSQUqvYJ1f2mLtinVhV
|
|
1603
|
-
# Prefix: 42
|
|
1792
|
+
# Name: Treasury
|
|
1793
|
+
# Address: 5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z
|
|
1794
|
+
# Source: pallet py/trsry (0x70792f7472737279)
|
|
1604
1795
|
|
|
1605
|
-
#
|
|
1606
|
-
dot
|
|
1796
|
+
# Pallet sovereign — 0x-prefixed hex (16 hex chars)
|
|
1797
|
+
dot account add Bounties --pallet-id 0x70792f626f756e74
|
|
1607
1798
|
|
|
1608
|
-
#
|
|
1609
|
-
dot parachain
|
|
1799
|
+
# Parachain sovereign — child (relay-chain side) — type is required
|
|
1800
|
+
dot account add People --parachain 1004 --parachain-type child
|
|
1801
|
+
# Output:
|
|
1802
|
+
# Account Added (watch-only)
|
|
1803
|
+
#
|
|
1804
|
+
# Name: People
|
|
1805
|
+
# Address: 5Ec4AhPaYcfBz8fMoPd4EfnAgwbzRS7np3APZUnnFo12qEYk
|
|
1806
|
+
# Source: parachain 1004 (child sovereign)
|
|
1610
1807
|
|
|
1611
|
-
#
|
|
1612
|
-
dot parachain
|
|
1808
|
+
# Parachain sovereign — sibling (XCM peer side)
|
|
1809
|
+
dot account add People-Sibling --parachain 1004 --parachain-type sibling
|
|
1613
1810
|
|
|
1614
|
-
# JSON output
|
|
1615
|
-
dot
|
|
1616
|
-
# Output:
|
|
1811
|
+
# JSON output includes a `derivation` object describing the source
|
|
1812
|
+
dot account add Bnt --pallet-id py/bount --json
|
|
1617
1813
|
# {
|
|
1618
|
-
# "
|
|
1619
|
-
# "
|
|
1620
|
-
# "
|
|
1621
|
-
# "
|
|
1814
|
+
# "name": "Bnt",
|
|
1815
|
+
# "address": "5EYCAe5ijiYdYTM8d3VytEARdH7dFp4rdCPpAsPXrfopdm7d",
|
|
1816
|
+
# "watchOnly": true,
|
|
1817
|
+
# "derivation": {
|
|
1818
|
+
# "kind": "pallet",
|
|
1819
|
+
# "palletId": "py/bount",
|
|
1820
|
+
# "palletIdHex": "0x70792f626f756e74"
|
|
1821
|
+
# }
|
|
1622
1822
|
# }
|
|
1823
|
+
|
|
1824
|
+
# Stored sovereigns appear alongside other accounts
|
|
1825
|
+
dot account list
|
|
1623
1826
|
```
|
|
1624
1827
|
|
|
1625
|
-
|
|
1828
|
+
#### Discovering a chain's PalletId
|
|
1829
|
+
|
|
1830
|
+
Pallets that need a sovereign account expose their `PalletId` as a runtime constant. Read it via the `const` category and feed the hex straight into `--pallet-id`:
|
|
1831
|
+
|
|
1832
|
+
```bash
|
|
1833
|
+
# Pre-req: metadata cached for the chain (e.g. `dot chain update polkadot`)
|
|
1834
|
+
dot polkadot.const.Treasury.PalletId
|
|
1835
|
+
# Output (JSON-quoted hex):
|
|
1836
|
+
# "0x70792f7472737279"
|
|
1837
|
+
|
|
1838
|
+
# Pipe into the add command (strip JSON quotes with tr)
|
|
1839
|
+
dot account add Treasury --pallet-id "$(dot polkadot.const.Treasury.PalletId | tr -d '"')"
|
|
1840
|
+
```
|
|
1841
|
+
|
|
1842
|
+
There is no central registry of "well-known" PalletIds — each runtime author picks the 8 bytes when wiring up a pallet's `Config`. The chain's metadata is the authoritative source for that chain's values.
|
|
1843
|
+
|
|
1844
|
+
#### Constraints
|
|
1845
|
+
|
|
1846
|
+
- `--parachain` requires `--parachain-type child|sibling` (no implicit default — picking the wrong one silently produces a different address).
|
|
1847
|
+
- `--parachain` and `--pallet-id` are mutually exclusive.
|
|
1848
|
+
- A positional address (`dot account add foo <ss58>`) cannot be combined with derivation flags.
|
|
1849
|
+
- Derivation flags cannot be combined with `--secret` or `--env` — a derived sovereign has no signing key.
|
|
1850
|
+
|
|
1851
|
+
#### Legacy `dot parachain` command (deprecated)
|
|
1852
|
+
|
|
1853
|
+
The standalone `dot parachain <paraId>` command from earlier releases is **still available for backward compatibility** and now prints a deprecation warning to stderr. Stdout output is unchanged, so existing pipes (e.g. `dot parachain 1000 --json | jq`) keep working. Migrate to `dot account inspect --parachain <id> --parachain-type <child|sibling>` at your convenience — it will be removed in a future release ([#208](https://github.com/peetzweg/polkadot-cli/issues/208)).
|
|
1854
|
+
|
|
1855
|
+
```bash
|
|
1856
|
+
# Old (deprecated, still works — emits stderr warning)
|
|
1857
|
+
dot parachain 1000 --type child --json
|
|
1858
|
+
|
|
1859
|
+
# New
|
|
1860
|
+
dot account inspect --parachain 1000 --parachain-type child --json
|
|
1861
|
+
```
|
|
1626
1862
|
|
|
1627
1863
|
### Bandersnatch member keys
|
|
1628
1864
|
|