cardano course
  • Welcome!
  • Video lessons
  • Handbook
    • Module 1. Building and running the node
      • Building the node
      • Running the node and connecting to a network
    • Module 2. Basic operations
      • Creating keys and addresses
      • Creating a simple transaction
      • Registering the stake address and delegating
    • Module 3. Protocol parameters and configuration files
      • Protocol parameters
      • Byron genesis file
      • Shelley genesis file
      • Alonzo genesis file
      • Conway genesis file
      • Node configuration file
      • Topology file
    • Module 4. Peer-to-peer (P2P) networking
    • Module 5. Creating a stake pool
      • The setup
      • Generating keys
      • Registering a stake pool
      • Runtime system options
      • Running the nodes
      • Stake snapshots
      • Upgrading cardano-node and cardano-cli
      • Pool operations and maintenance
      • Retiring a stake pool
    • Module 6. Monitoring the nodes
    • Module 7. Cardano governance
      • Update proposals
      • Polls
    • Module 8. Setting up a local cluster
      • Creating a local cluster
      • Spending the genesis UTXO
      • From Byron to Shelley
      • Moving funds to a Shelley address
      • Creating a first stake pool
      • Bringing decentralization parameter down to .80
      • From Shelley to Alonzo
      • Creating a second stake pool before moving to the Babbage era
      • Redelegating genesis keys
      • Vasil hard fork
      • Creating a local cluster with the mkfiles script
    • Module 9. Simple scripts and Plutus scripts
    • Module 10. New tracing system
    • Module 11. Running the SMASH server
    • Module 12. Running the token metadata server
  • Curated playlist
Powered by GitBook
On this page
  • A quick look at addresses
  • Generating a payment key pair and an address
  • Building an address
  • Installing cardano-address
  • Querying the address balance
  • Generating a stake key pair and a type 0 address

Was this helpful?

Edit on GitHub
  1. Handbook
  2. Module 2. Basic operations

Creating keys and addresses

PreviousModule 2. Basic operationsNextCreating a simple transaction

Last updated 1 year ago

Was this helpful?

A quick look at addresses

Create a directory for your keys:

mkdir -p keys
cd keys

Generating a payment key pair and an address

To generate a key pair, run:

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

Building an address

Generate a type 6 address, the associated stake of which cannot be delegated:

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

Installing cardano-address

Just for fun, let's install cardano-address

Go to the previously created src directory:

wget https://github.com/input-output-hk/cardano-addresses/releases/download/3.12.0/cardano-addresses-3.12.0-linux64.tar.gz
tar -xf cardano-addresses-3.12.0-linux64.tar.gz
chmod +x bin/cardano-address
mv bin/cardano-address ~/.local/bin/

You can use cardano-address to inspect the address. Back to the keys directory

cat payment.addr | cardano-address address inspect

you should see something like:

{
    "stake_reference": "none",
    "spending_key_hash_bech32": "addr_vkh1tc0da5jwszr8f875jcpdmx3lmfgfcuxxvexggufyvmnhg3r5p2x",
    "address_style": "Shelley",
    "spending_key_hash": "5e1eded24e8086749fd49602dd9a3fda509c70c6664c84712466e774",
    "network_tag": 0,
    "address_type": 6
}

Now, you can get some funds from the faucet:

Querying the address balance

If successful, you can use cardano-cli to verify that you have received the funds:

cardano-cli query utxo --address $(cat payment.addr) --testnet-magic 2

cardanoscan.io will also show the transaction:

Generating a stake key pair and a type 0 address

cardano-cli stake-address key-gen \
--verification-key-file stake.vkey \
--signing-key-file stake.skey
cardano-cli address build \
--payment-verification-key-file payment.vkey \
--stake-verification-key-file stake.vkey \
--out-file paymentwithstake.addr \
--testnet-magic 2
cat paymentwithstake.addr | cardano-address address inspect

You should see something like this:

{
    "stake_reference": "by value",
    "stake_key_hash_bech32": "stake_vkh1kevs5lhejnxy3j6dnq8wsh6k66e6yn8atev5e3jy7asajygx8zx",
    "stake_key_hash": "b6590a7ef994cc48cb4d980ee85f56d6b3a24cfd5e594cc644f761d9",
    "spending_key_hash_bech32": "addr_vkh1tc0da5jwszr8f875jcpdmx3lmfgfcuxxvexggufyvmnhg3r5p2x",
    "address_style": "Shelley",
    "spending_key_hash": "5e1eded24e8086749fd49602dd9a3fda509c70c6664c84712466e774",
    "network_tag": 0,
    "address_type": 0
}
Page cover image
https://cips.cardano.org/cips/cip19/
LogoReleases · input-output-hk/cardano-addressesGitHub
LogoTestnets faucet
LogoPreProd Cardanoscan - Cardano Explorer