polkadot-cli 1.17.0 → 1.18.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 +196 -38
  2. package/dist/cli.mjs +1214 -89
  3. package/package.json +2 -1
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
- - ✅ Parachain sovereign accounts — derive child and sibling addresses from a parachain ID
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` with a `(watch-only)` badge and can be inspected and removed like any other account. They cannot be used with `--from` (signing) or as a source for `derive`.
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
@@ -388,7 +391,8 @@ dot account inspect alice --json
388
391
  # "publicKey": "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d",
389
392
  # "ss58": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
390
393
  # "prefix": 42,
391
- # "name": "Alice"
394
+ # "name": "Alice",
395
+ # "kind": "dev"
392
396
  # }
393
397
  ```
394
398
 
@@ -400,11 +404,52 @@ dot account inspect alice
400
404
  # Account Info
401
405
  #
402
406
  # Name: Alice
407
+ # Kind: dev
403
408
  # Public Key: 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
404
409
  # SS58: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
405
410
  # Prefix: 42
406
411
  ```
407
412
 
413
+ 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`), or `parachain sovereign (child|sibling)` (derived from a parachain ID). 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.
414
+
415
+ ##### Stateless sovereign derivation (script-friendly)
416
+
417
+ 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:
418
+
419
+ ```bash
420
+ # Polkadot Treasury — pallet sovereign on prefix 0
421
+ dot account inspect --pallet-id py/trsry --prefix 0
422
+ # Output:
423
+ # Account Info
424
+ #
425
+ # Kind: pallet sovereign
426
+ # Public Key: 0x6d6f646c70792f74727372790000000000000000000000000000000000000000
427
+ # SS58: 13UVJyLnbVp9RBZYFwFGyDvVd1y27Tt8tkntv6Q7JVPhFsTB
428
+ # Source: PalletId py/trsry (0x70792f7472737279)
429
+ # Prefix: 0
430
+
431
+ # Hex form works the same
432
+ dot account inspect --pallet-id 0x70792f7472737279 --prefix 0
433
+
434
+ # Parachain sovereigns (type is required — child = on relay, sibling = on another parachain)
435
+ dot account inspect --parachain 1004 --parachain-type child
436
+
437
+ # Pipeline: just the SS58
438
+ SS58=$(dot account inspect --pallet-id py/trsry --prefix 0 --json | jq -r .ss58)
439
+
440
+ # JSON shape includes a `source` object describing the derivation
441
+ dot account inspect --pallet-id py/trsry --json
442
+ # {
443
+ # "publicKey": "0x6d6f646c70792f74727372790000000000000000000000000000000000000000",
444
+ # "ss58": "5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z",
445
+ # "prefix": 42,
446
+ # "kind": "pallet sovereign",
447
+ # "source": { "kind": "pallet", "palletId": "py/trsry", "palletIdHex": "0x70792f7472737279" }
448
+ # }
449
+ ```
450
+
451
+ 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).
452
+
408
453
  #### Reveal the sr25519 private key
409
454
 
410
455
  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 +471,7 @@ dot account add ci-signer --env MY_SECRET
426
471
 
427
472
  `--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
473
 
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` shows an `(env: MY_SECRET)` badge and resolves the address live when the variable is available.
474
+ 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
475
 
431
476
  #### Derivation paths
432
477
 
@@ -448,11 +493,15 @@ dot account derive treasury treasury-staking --path //staking
448
493
 
449
494
  `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
495
 
451
- `account list` shows the derivation path next to the account name:
496
+ `account list` shows derivation paths and env sources on tree-style continuation lines (label names mirror the `--flag` that sets them):
452
497
 
453
498
  ```
454
- treasury-staking (//staking) 5FHneW46...
455
- ci-signer (//ci) (env: MY_SECRET) 5EPCUjPx...
499
+ Signers
500
+ treasury-staking 5FHneW46...
501
+ └─ path: //staking
502
+ ci-signer 5EPCUjPx...
503
+ ├─ path: //ci
504
+ └─ env: $MY_SECRET
456
505
  ```
457
506
 
458
507
  **Supported secret formats for import:**
@@ -532,7 +581,7 @@ dot polkadot.apis.Core
532
581
  dot apis Core --chain polkadot
533
582
  ```
534
583
 
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.
584
+ 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
585
 
537
586
  ### Query storage
538
587
 
@@ -963,6 +1012,74 @@ The list view tags each entry:
963
1012
 
964
1013
  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
1014
 
1015
+ ### Raw JSON-RPC
1016
+
1017
+ 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.
1018
+
1019
+ 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.
1020
+
1021
+ ```bash
1022
+ # List all methods the node exposes, grouped by family
1023
+ dot polkadot.rpc
1024
+ # Output:
1025
+ # RPC methods on polkadot (129)
1026
+ #
1027
+ # system (20)
1028
+ # system_health Node sync state (peers, isSyncing, shouldHavePeers).
1029
+ # system_version Node software version string.
1030
+ # system_chain Chain name as reported by the node.
1031
+ # ...
1032
+ # chain (19)
1033
+ # chain_getBlock Full block (header + extrinsics) by hash.
1034
+ # chain_getFinalizedHead Hash of the latest finalized head.
1035
+ # ...
1036
+
1037
+ # Call a method
1038
+ dot polkadot.rpc.system_health
1039
+ # Output:
1040
+ # {
1041
+ # "peers": 131,
1042
+ # "isSyncing": false,
1043
+ # "shouldHavePeers": true
1044
+ # }
1045
+
1046
+ # Positional args (parsed by the same heuristic as tx args)
1047
+ dot polkadot.rpc.chain_getBlockHash 1000
1048
+ # Output:
1049
+ # "0xcf36a1e4a16fc579136137b8388f35490f09c5bdd7b9133835eba907a8b76c30"
1050
+
1051
+ # Show curated info for a known method
1052
+ dot polkadot.rpc.author_insertKey --help
1053
+ # Output:
1054
+ # author_insertKey
1055
+ # ⚠️ WRITE / state-changing
1056
+ # Insert a key into the node keystore.
1057
+ #
1058
+ # Family: author
1059
+ # Args: <keyType: string> <suri: string> <publicKey: hex>
1060
+
1061
+ # Refresh the cached method list (after a node upgrade)
1062
+ dot polkadot.rpc --refresh
1063
+
1064
+ # JSON output works on any method
1065
+ dot polkadot.rpc.system_health --json
1066
+ ```
1067
+
1068
+ `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.
1069
+
1070
+ 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.
1071
+
1072
+ 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:
1073
+
1074
+ ```bash
1075
+ dot polkadot.rpc.chain_subscribeAllHeads
1076
+ # Error: "chain_subscribeAllHeads" is a subscription method (requires a follow
1077
+ # session) and is not callable as a one-shot. Use a long-running client for
1078
+ # streaming RPC.
1079
+ ```
1080
+
1081
+ 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`).
1082
+
966
1083
  ### Submit extrinsics
967
1084
 
968
1085
  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.
@@ -1579,50 +1696,91 @@ Output shows the crypto type, message bytes in hex, raw signature, and an `Enum`
1579
1696
 
1580
1697
  Use `--type` to select the signature algorithm (default: `sr25519`). Run `dot sign` with no arguments to see usage and examples.
1581
1698
 
1582
- ### Parachain sovereign accounts
1699
+ ### Sovereign accounts (parachain & pallet)
1700
+
1701
+ `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
1702
 
1584
- Derive the sovereign account addresses for a parachain. These are deterministic accounts derived from a parachain ID — no chain connection required.
1703
+ Two kinds of sovereign:
1585
1704
 
1586
- - **Child** accounts represent a parachain on the relay chain (prefix `"para"`)
1587
- - **Sibling** accounts represent a parachain on another parachain (prefix `"sibl"`)
1705
+ - **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`.)
1706
+ - **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
1707
 
1589
1708
  ```bash
1590
- # Show both child and sibling accounts
1591
- dot parachain 1000
1709
+ # Pallet sovereign ASCII PalletId
1710
+ dot account add Treasury --pallet-id py/trsry
1592
1711
  # Output:
1593
- # Parachain 1000 — Sovereign Accounts
1712
+ # Account Added (watch-only)
1594
1713
  #
1595
- # Child:
1596
- # Public Key: 0x70617261e8030000000000000000000000000000000000000000000000000000
1597
- # SS58: 5Ec4AhPZk8STuex8Wsi9TwDtJQxKqzPJRCH7348Xtcs9vZLJ
1598
- # Prefix: 42
1599
- #
1600
- # Sibling:
1601
- # Public Key: 0x7369626ce8030000000000000000000000000000000000000000000000000000
1602
- # SS58: 5Eg2fntNprdN3FgH4sfEaaZhYtddZQSQUqvYJ1f2mLtinVhV
1603
- # Prefix: 42
1714
+ # Name: Treasury
1715
+ # Address: 5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z
1716
+ # Source: pallet py/trsry (0x70792f7472737279)
1604
1717
 
1605
- # Show only the child (relay chain) account
1606
- dot parachain 2004 --type child
1718
+ # Pallet sovereign 0x-prefixed hex (16 hex chars)
1719
+ dot account add Bounties --pallet-id 0x70792f626f756e74
1607
1720
 
1608
- # Show only the sibling (parachain-to-parachain) account
1609
- dot parachain 2004 --type sibling
1721
+ # Parachain sovereign child (relay-chain side) — type is required
1722
+ dot account add People --parachain 1004 --parachain-type child
1723
+ # Output:
1724
+ # Account Added (watch-only)
1725
+ #
1726
+ # Name: People
1727
+ # Address: 5Ec4AhPaYcfBz8fMoPd4EfnAgwbzRS7np3APZUnnFo12qEYk
1728
+ # Source: parachain 1004 (child sovereign)
1610
1729
 
1611
- # Use Polkadot SS58 prefix (default: 42)
1612
- dot parachain 1000 --prefix 0
1730
+ # Parachain sovereign sibling (XCM peer side)
1731
+ dot account add People-Sibling --parachain 1004 --parachain-type sibling
1613
1732
 
1614
- # JSON output
1615
- dot parachain 1000 --json
1616
- # Output:
1733
+ # JSON output includes a `derivation` object describing the source
1734
+ dot account add Bnt --pallet-id py/bount --json
1617
1735
  # {
1618
- # "paraId": 1000,
1619
- # "prefix": 42,
1620
- # "child": { "publicKey": "0x70617261...", "ss58": "5Ec4AhPZ..." },
1621
- # "sibling": { "publicKey": "0x7369626c...", "ss58": "5Eg2fntN..." }
1736
+ # "name": "Bnt",
1737
+ # "address": "5EYCAe5ijiYdYTM8d3VytEARdH7dFp4rdCPpAsPXrfopdm7d",
1738
+ # "watchOnly": true,
1739
+ # "derivation": {
1740
+ # "kind": "pallet",
1741
+ # "palletId": "py/bount",
1742
+ # "palletIdHex": "0x70792f626f756e74"
1743
+ # }
1622
1744
  # }
1745
+
1746
+ # Stored sovereigns appear alongside other accounts
1747
+ dot account list
1748
+ ```
1749
+
1750
+ #### Discovering a chain's PalletId
1751
+
1752
+ 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`:
1753
+
1754
+ ```bash
1755
+ # Pre-req: metadata cached for the chain (e.g. `dot chain update polkadot`)
1756
+ dot polkadot.const.Treasury.PalletId
1757
+ # Output (JSON-quoted hex):
1758
+ # "0x70792f7472737279"
1759
+
1760
+ # Pipe into the add command (strip JSON quotes with tr)
1761
+ dot account add Treasury --pallet-id "$(dot polkadot.const.Treasury.PalletId | tr -d '"')"
1623
1762
  ```
1624
1763
 
1625
- Run `dot parachain` with no arguments to see usage and examples.
1764
+ 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.
1765
+
1766
+ #### Constraints
1767
+
1768
+ - `--parachain` requires `--parachain-type child|sibling` (no implicit default — picking the wrong one silently produces a different address).
1769
+ - `--parachain` and `--pallet-id` are mutually exclusive.
1770
+ - A positional address (`dot account add foo <ss58>`) cannot be combined with derivation flags.
1771
+ - Derivation flags cannot be combined with `--secret` or `--env` — a derived sovereign has no signing key.
1772
+
1773
+ #### Legacy `dot parachain` command (deprecated)
1774
+
1775
+ 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)).
1776
+
1777
+ ```bash
1778
+ # Old (deprecated, still works — emits stderr warning)
1779
+ dot parachain 1000 --type child --json
1780
+
1781
+ # New
1782
+ dot account inspect --parachain 1000 --parachain-type child --json
1783
+ ```
1626
1784
 
1627
1785
  ### Bandersnatch member keys
1628
1786