Delegating to a Stake Pool
✅ Prerequisites
Both a payment and a stake key pair. Payment key should contain some ADA.
👩💻 Registering Your Stake Address
Create a certificate, stake.cert, using the stake.vkey
cardano-cli stake-address registration-certificate \
--stake-verification-key-file stake.vkey \
--out-file stake.certYou need to find the slot tip of the blockchain.
currentSlot=$(cardano-cli query tip --mainnet | jq -r '.slot')
echo Current Slot: $currentSlotFind your balance and UTXOs.
cardano-cli query utxo \
--address $(cat payment.addr) \
--mainnet > fullUtxo.out
tail -n +3 fullUtxo.out | sort -k3 -nr > balance.out
cat balance.out
tx_in=""
total_balance=0
while read -r utxo; do
type=$(awk '{ print $6 }' <<< "${utxo}")
if [[ ${type} == 'TxOutDatumNone' ]]
then
in_addr=$(awk '{ print $1 }' <<< "${utxo}")
idx=$(awk '{ print $2 }' <<< "${utxo}")
utxo_balance=$(awk '{ print $3 }' <<< "${utxo}")
total_balance=$((${total_balance}+${utxo_balance}))
echo TxHash: ${in_addr}#${idx}
echo ADA: ${utxo_balance}
tx_in="${tx_in} --tx-in ${in_addr}#${idx}"
fi
done < balance.out
txcnt=$(cat balance.out | wc -l)
echo Total available ADA balance: ${total_balance}
echo Number of UTXOs: ${txcnt}Find the stakeAddressDeposit value.
Run the build-raw transaction command
Calculate the current minimum fee:
Calculate your change output.
Build your transaction which will register your stake address.
Sign the transaction with both the payment and stake secret keys.
Send the signed transaction.
📄 Creating a Delegation Certificate
Given its stake pool verification key file node.vkey , from your stakepool should have generated (and published) a stake pool ID:
Given the stake pool ID from your stakepool, run the following:
You need to find the tip of the blockchain to set the ttl parameter properly.
Find your balance and UTXOs.
Run the build-raw transaction command.
Calculate the minimum fee:
Calculate your change output.
Build the transaction.
Sign the transaction.
Send the transaction.
Congratulations! Your ADA is now successfully delegated to your chosen stakepool.