~zinigor/cardano-node/trunk

« back to all changes in this revision

Viewing changes to doc/stake-pool-operations/keys_and_addresses.md

  • Committer: Igor Zinovyev
  • Date: 2021-08-13 19:12:27 UTC
  • Revision ID: zinigor@gmail.com-20210813191227-stlnsj3mc5ypwn0c
Tags: upstream-1.27.0
ImportĀ upstreamĀ versionĀ 1.27.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Creating keys and addresses
 
2
 
 
3
In the Shelley era of Cardano, every stakeholder can have two sets of keys and addresses:
 
4
 
 
5
* Payment Keys and addresses: To send and receive transactions
 
6
* Stake Keys and addresses: To control protocol participation, create a stake pool, delegate and receive rewards.
 
7
 
 
8
#### Payment key pair
 
9
 
 
10
To generate a _payment key pair_:
 
11
 
 
12
```
 
13
cardano-cli address key-gen \
 
14
--verification-key-file payment.vkey \
 
15
--signing-key-file payment.skey
 
16
```
 
17
This creates two files `payment.vkey` (the _public verification key_) and `payment.skey` (the _private signing key_).
 
18
 
 
19
#### Legacy key
 
20
 
 
21
To generate Byron-era _payment key:
 
22
 
 
23
Payment key files use the following format:
 
24
```json
 
25
{
 
26
    "type": "PaymentSigningKeyByron_ed25519_bip32",
 
27
    "description": "Payment Signing Key",
 
28
    "cborHex": "hex-here"
 
29
}
 
30
```
 
31
 
 
32
Where the `hex-here` is generated as `0x5880 | xprv | pub | chaincode`
 
33
 
 
34
#### Stake key pair
 
35
To generate a _stake key pair_ :
 
36
 
 
37
```
 
38
cardano-cli stake-address key-gen \
 
39
--verification-key-file stake.vkey \
 
40
--signing-key-file stake.skey
 
41
```
 
42
#### Payment address
 
43
Both verification keys (`payment.vkey` and `stake.vkey`) are used to build the address and the resulting `payment address` is associated with these keys.
 
44
 
 
45
```
 
46
cardano-cli address build \
 
47
--payment-verification-key-file payment.vkey \
 
48
--stake-verification-key-file stake.vkey \
 
49
--out-file payment.addr \
 
50
--mainnet
 
51
```
 
52
#### Stake address
 
53
 
 
54
To generate a `stake address`:
 
55
 
 
56
```
 
57
cardano-cli stake-address build \
 
58
--stake-verification-key-file stake.vkey \
 
59
--out-file stake.addr \
 
60
--mainnet
 
61
```
 
62
This address __CAN'T__ receive payments but will receive the rewards from participating in the protocol.
 
63
 
 
64
 
 
65
#### Query the balance of an address
 
66
 
 
67
> NOTE: Ensure that your node has synced to the current block height which can be checked at [explorer.cardano.org](https://explorer.cardano.org). If it is not, you may see an error referring to the Byron Era.
 
68
 
 
69
To query the balance of an address we need a running node and the environment variable `CARDANO_NODE_SOCKET_PATH` set to the path of the node.socket:
 
70
 
 
71
```
 
72
cardano-cli query utxo \
 
73
--address $(cat payment.addr) \
 
74
--mainnet
 
75
```
 
76
```
 
77
                            TxHash                                 TxIx        Amount
 
78
--------------------------------------------------------------------------------------------
 
79
```
 
80
 
 
81
**Note**`--mainnet` identifies the Cardano mainnet, for testnets use `--testnet-magic 1097911063` instead.