Stake Pool Registration

From Cardano Blockchain Wiki
Jump to navigation Jump to search

Stake Address Registration

Registering the stake address to the blockchain pays a transaction fee but also needs a deposit. We can check the protocol parameters to learn how much we need to pay as a deposit. We can get the deposit back when we deregister the stake key.

cat protocol.json | grep stakeAddressDeposit
"stakeAddressDeposit": 2000000,
cardano-cli query utxo \
    --address $(cat payment.addr) \
    --mainnet

#                           TxHash                                 TxIx        Amount
#--------------------------------------------------------------------------------------
#111b132ebf7406a9ece4583c1a5501db16cadf43409417d63f6034cb6f3f22a     0        10000000 lovelace + TxOutDatumNone


cardano-cli transaction build-raw \
    --tx-in <TxHash>#<TxIx> \
    --tx-out $(cat payment.addr)+0 \
    --fee 0 \
    --certificate-file stake.cert \
    --out-file tx.draft

cardano-cli transaction calculate-min-fee \
   --tx-body-file tx.draft \
   --tx-in-count 1 \
   --tx-out-count 1 \
   --witness-count 2 \
   --mainnet \
   --protocol-params-file protocol.json

# 178437 Lovelace

# Amount = Total - stakeAddressDeposit - Fee = 10000000 - 2000000 - 178437 = 7821563 Lovelace
# Build the transaction with all the data
cardano-cli transaction build-raw \
   --tx-in <TxHash>#<TxIx> \
   --tx-out $(cat payment.addr)+<Amount> \
   --fee <Fee> \
   --certificate-file stake.cert \
   --out-file tx.raw

# Sign the transaction, both with the payment.skey and the stake,skey 
cardano-cli transaction sign \
    --mainnet \
    --tx-body-file tx.raw \
    --signing-key-file payment.skey \
    --signing-key-file stake.skey \
    --out-file tx.signed

cardano-cli transaction submit \
    --mainnet \
    --tx-file tx.signed 

# Transaction successfully submitted.

Stake Pool Registration

cardano-cli query tip --mainnet
# {
#     "block": 7769026,
#     "epoch": 363,
#     "era": "Alonzo",
#     "hash": "20ab82502c552fd2f0c1a4aa68f8b6e72e421f7e56bb6a071f76b711abfe3e34",
#     "slot": 71849653,
#     "syncProgress": "100.00"
# }

# Ttl = 71873928 + 1000

cardano-cli query utxo \
    --address $(cat payment.addr) \
    --mainnet

#                            TxHash                                 TxIx        Amount
# --------------------------------------------------------------------------------------
# 1116cab36f08ee28984c5f43ed882b14d6d34ccffa9b2b2b4e05235e9a70d11a     0        7821563 lovelace + TxOutDatumNone

cardano-cli transaction build-raw \
    --tx-in <TxHash>#<TxIx> \
    --tx-out $(cat payment.addr)+0 \
    --ttl 0 \
    --fee 0 \
    --out-file tx.raw \
    --certificate-file pool-registration.cert \
    --certificate-file delegation.cert


cardano-cli transaction calculate-min-fee \
    --tx-body-file tx.raw \
    --tx-in-count 1 \
    --tx-out-count 1 \
    --mainnet \
    --witness-count 3 \
    --byron-witness-count 0 \
    --protocol-params-file protocol.json

# Deposit = 500000000 (only first time)
# Fee = 184377 lovelace
# Change = Amount - poolDeposit - Fee

cardano-cli transaction build-raw \
    --tx-in <TxHash>#<TxIx> \
    --tx-out $(cat payment.addr)+<Change> \
    --ttl <Ttl> \
    --fee <Fee> \
    --certificate-file pool-registration.cert \
    --certificate-file delegation.cert \
    --out-file tx.raw

cardano-cli transaction sign \
    --tx-body-file tx.raw \
    --signing-key-file payment.skey \
    --signing-key-file stake.skey \
    --signing-key-file cold.skey \
    --mainnet \
    --out-file tx.signed

cardano-cli transaction submit \
    --tx-file tx.signed \
    --mainnet