1
# Creating keys and addresses
3
In the Shelley era of Cardano, every stakeholder can have two sets of keys and addresses:
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.
10
To generate a _payment key pair_:
13
cardano-cli address key-gen \
14
--verification-key-file payment.vkey \
15
--signing-key-file payment.skey
17
This creates two files `payment.vkey` (the _public verification key_) and `payment.skey` (the _private signing key_).
21
To generate Byron-era _payment key:
23
Payment key files use the following format:
26
"type": "PaymentSigningKeyByron_ed25519_bip32",
27
"description": "Payment Signing Key",
32
Where the `hex-here` is generated as `0x5880 | xprv | pub | chaincode`
35
To generate a _stake key pair_ :
38
cardano-cli stake-address key-gen \
39
--verification-key-file stake.vkey \
40
--signing-key-file stake.skey
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.
46
cardano-cli address build \
47
--payment-verification-key-file payment.vkey \
48
--stake-verification-key-file stake.vkey \
49
--out-file payment.addr \
54
To generate a `stake address`:
57
cardano-cli stake-address build \
58
--stake-verification-key-file stake.vkey \
59
--out-file stake.addr \
62
This address __CAN'T__ receive payments but will receive the rewards from participating in the protocol.
65
#### Query the balance of an address
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.
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:
72
cardano-cli query utxo \
73
--address $(cat payment.addr) \
78
--------------------------------------------------------------------------------------------
81
**Note**`--mainnet` identifies the Cardano mainnet, for testnets use `--testnet-magic 1097911063` instead.