mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
46095af452
* Add SS58 public key encoding. * [Companion] Update Cargo.toml subkey version, readme to reflect new output (#8694) * Update Cargo.toml * update cargo, readme for subkey Co-authored-by: Dan Shields <danwshields@gmail.com> Co-authored-by: Dan Shields <35669742+NukeManDan@users.noreply.github.com> Co-authored-by: Dan Shields <danwshields@gmail.com>
92 lines
2.9 KiB
Plaintext
92 lines
2.9 KiB
Plaintext
= Subkey
|
|
|
|
Subkey is a commandline utility included with Substrate that generates or restores Substrate keys.
|
|
|
|
`subkey` will use the http://wiki.polkadot.network/en/latest/polkadot/learn/cryptography/#keypairs-and-signing[sr25519] cryptography by default. If you need to use the older ed25519 cryptography to generate or restore your key pass the `--ed25519` flag to any of the commands.
|
|
|
|
== Usage
|
|
|
|
=== Generate a random account
|
|
|
|
```bash
|
|
subkey generate
|
|
```
|
|
|
|
Will output a secret phrase("mnemonic phrase") and give you the secret seed("Private Key"), public key("Account ID") and SS58 address("Public Address") of a new account. DO NOT SHARE your mnemonic phrase or secret seed with ANYONE it will give them access to your funds. If someone is making a transfer to you they will only need your **Public Address**.
|
|
|
|
=== Inspecting a key
|
|
|
|
You can inspect a given URI (mnemonic, seed, public key, or address) and recover the public key and the address.
|
|
|
|
```bash
|
|
subkey inspect <mnemonic,seed,pubkey,address>
|
|
```
|
|
_Example Output_:
|
|
```
|
|
Secret Key URI `` is account:
|
|
Secret seed: 0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e
|
|
Public key (hex): 0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a
|
|
Public key (SS58): 5DfhGyQdFobKM8NsWvEeAKk5EQQgYe9AydgJ7rMB6E1EqRzV
|
|
Account ID: 0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a
|
|
SS58 Address: 5DfhGyQdFobKM8NsWvEeAKk5EQQgYe9AydgJ7rMB6E1EqRzV
|
|
```
|
|
|
|
=== Signing
|
|
|
|
`subkey` expects a message to come in on STDIN, one way to sign a message would look like this:
|
|
|
|
```bash
|
|
echo -n <msg> | subkey sign --suri <seed,mnemonic>
|
|
```
|
|
_Example Output_:
|
|
```
|
|
a69da4a6ccbf81dbbbfad235fa12cf8528c18012b991ae89214de8d20d29c1280576ced6eb38b7406d1b7e03231df6dd4a5257546ddad13259356e1c3adfb509
|
|
```
|
|
|
|
=== Verifying a signature
|
|
|
|
```bash
|
|
echo -n <msg> | subkey verify <sig> <address>
|
|
|
|
OUTPUT:
|
|
Signature verifies correctly.
|
|
```
|
|
|
|
=== Using the vanity generator
|
|
|
|
You can use the included vanity generator to find a seed that provides an address which includes the desired pattern. Be warned, depending on your hardware this may take a while.
|
|
|
|
```bash
|
|
subkey vanity 1337
|
|
```
|
|
|
|
=== Signing a transaction
|
|
|
|
Sign a transaction from an encoded `Call`.
|
|
|
|
```bash
|
|
subkey sign-transaction \
|
|
--call <call-as-hex> \
|
|
--nonce 0 \
|
|
--suri <secret-uri> \
|
|
--password <password> \
|
|
--prior-block-hash <prior-block-hash-as-hex>
|
|
```
|
|
|
|
Will output a signed and encoded `UncheckedMortalCompactExtrinsic` as hex.
|
|
|
|
=== Inspecting a module ID
|
|
|
|
```bash
|
|
subkey module-id "py/trsry" --network kusama
|
|
```
|
|
_Example Output_:
|
|
```
|
|
Public Key URI `F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29` is account:
|
|
Network ID/version: kusama
|
|
Public key (hex): 0x6d6f646c70792f74727372790000000000000000000000000000000000000000
|
|
Public key (SS58): F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29
|
|
Account ID: 0x6d6f646c70792f74727372790000000000000000000000000000000000000000
|
|
SS58 Address: F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29
|
|
```
|