Generate payment keys and addresses

We need to create two sets of keys and addresses. One set to control our funds (make and receive payments) and one set to control our stake (to participate in the protocol delegating our stake)

Let's produce our cryptographic keys first, as we will need them to later create our addresses:

WARNING

For ease of use, and for this course only, we will keep our Cardano Testnet key files in the server. But this is NOT SECURE.

In a real life scenario (MAINNET), you need to have your keys under cold storage.

Payment key pair

Generate a payment key pair:

cardano-cli address key-gen \
--verification-key-file payment.vkey \
--signing-key-file payment.skey

This will create two files (here named payment.vkey and payment.skey), one containing the public verification key, one the private signing key.

The files are in plain-text format and human readable:

cat payment.vkey
> type: VerificationKeyShelley
> title: Free form text
> cbor-hex:
> 18af58...

The first line describes the file type and should not be changed. The second line is a free form text that we could change if we so wished. The key itself is the cbor-encoded byte-string in the fourth line.

Payment address

We then use payment.vkey and stake.vkey to create our payment address:

cardano-cli address build \
--payment-verification-key-file payment.vkey \
--out-file payment.addr \
--testnet-magic 1097911063

This created the file payment.addr that is already associated with our stake keys:

cat payment.addr
> addr_test1vrxfh9larxm7uhwfks4danzgffhsjkwwtxam6ad8sy7566sp0r7fj

To query your address (see the utxo's at that address), you first need to set environment variable CARDANO_NODE_SOCKET_PATH to the socket-path specified in your node configuration. In this example we will use the relay node created in the previous steps:

export CARDANO_NODE_SOCKET_PATH=~/relay/db/node.socket

make sure that your node is running. Then use cardano-cli shelley query utxo to find out the address' balance:

cardano-cli query utxo \
--allegra-era \
--address $(cat payment.addr) \
--testnet-magic 1097911063

you should see something like this:

TxHash TxIx Lovelace
----------------------------------------------------------------------------------

QUESTIONS AND FEEDBACK

If you have any questions and suggestions while taking the lessons please feel free to ask in the forum and we will respond as soon as possible.