Retiring a Stake Pool
If you ever decide that you no longer want to operate a Cardano stake pool, then you can retire the pool.
Retiring a pool involves submitting a stake pool deregistration certificate to the Cardano blockchain ledger. While submitting the transaction to retire a stake pool requires that Cardano Node instances in the stake pool configuration are fully synchronized with the network, valid KES keys are NOT required.
At the earliest, a stake pool deregistration certificate may take effect at the beginning of the next epoch. The stake address registered as the reward account for the stake pool receives the pool deposit refund. Therefore, you must wait until receiving the pool deposit refund prior to deregistering the stake address. If you deregister the stake address prior to receiving the pool deposit refund, then the pool deposit is nonreturnable. The Cardano Treasury receives nonreturnable stake pool deposits.
Note | Cardano CLI commands throughout the How to Set Up a Cardano Stake Pool guide may use the |
If you plan to retire a stake pool operating in the Mainnet environment having multiple pool owners, then communicate your intention to retire the pool to all pool owners in advance. To avoid risking losing fees for producing blocks, ensure that pool owners do NOT remove funds from accounts used to commit pledge until after the stake pool retires. To provide an opportunity for moving stakes to other pools, also give advance notice of the intention to retire the stake pool to delegators.
To retire a stake pool that you operate:
- On the block-producing node in your stake pool configuration, using a terminal window type the following commands to save protocol parameters:
cd $NODE_HOME
cardano-cli conway query protocol-parameters \
--mainnet \
--out-file params.json - When the local copy of the Cardano blockchain ledger is fully synchronized with the network, type the following commands to query the slot number of the current tip of the ledger:
currentSlot=$(cardano-cli conway query tip --mainnet | jq -r '.slot')
echo "Current Slot: ${currentSlot}" - To determine the current epoch number, type the following commands where
<EKGEndpoint>is the URL where the EKG endpoint for the local Cardano Node instance listens:currentEpoch=$(cardano-cli conway query tip --mainnet | jq -r '.epoch')
echo "Current Epoch: ${currentEpoch}"OR currentEpoch=$(curl -s -H 'Accept: application/json' <EKGEndpoint> | jq -r '.cardano.node.metrics.epoch.int.val')
echo "Current Epoch: ${currentEpoch}"OR startTimeGenesis=$(cat $NODE_HOME/shelley-genesis.json | jq -r '.systemStart')
startTimeSec=$(date --date=${startTimeGenesis} +%s)
currentTimeSec=$(date -u +%s)
epochLength=$(cat $NODE_HOME/shelley-genesis.json | jq -r '.epochLength')
currentEpoch=$(( (${currentTimeSec} - ${startTimeSec}) / ${epochLength} ))
echo "Current Epoch: ${currentEpoch}" - To determine the range of epochs when a stake pool currently can retire, type:
poolRetireMaxEpoch=$(cat $NODE_HOME/params.json | jq -r '.poolRetireMaxEpoch')
echo "The maximum number of epochs from now when a stake pool can retire is ${poolRetireMaxEpoch}"
minRetirementEpoch=$(( ${currentEpoch} + 1 ))
maxRetirementEpoch=$(( ${currentEpoch} + ${poolRetireMaxEpoch} ))
echo "Currently, the earliest a stake pool can retire is at the beginning of epoch ${minRetirementEpoch}"
echo "and the latest a stake pool can retire is at the beginning of epoch ${maxRetirementEpoch}" - To generate a stake pool deregistration certificate, type the following command where
<EpochToRetire>is a value between${minRetirementEpoch}and${maxRetirementEpoch}:cardano-cli conway stake-pool deregistration-certificate \
--cold-verification-key-file $NODE_HOME/node.vkey \
--epoch <EpochToRetire> \
--out-file $NODE_HOME/pool.dereg - To retrieve the UTXOs available for your payment address and calculate the balance, type:
# Retrieve the list of UTXOs available for your payment address
utxo_json=$(cardano-cli conway query utxo --output-json \
--address $(cat $NODE_HOME/payment.addr) \
--mainnet)
# Initialize variables
tx_in=""
total_balance=0
# Loop through the list of UTXOs
while read -r utxo; do
# Retrieve the values for the current UTXO
values=$(jq -r --arg k "${utxo}" '.[$k]' <<< "${utxo_json}")
# Retrieve datum associated with the UTXO
datum=$(jq -r '.datum' <<< "${values}")
# Retrieve the reference script associated with the UTXO
script=$(jq -r '.referenceScript' <<< "${values}")
# If limits on spending the UTXO may exist, then skip the UTXO
if [[ ${datum} == 'null' && ${script} == 'null' ]]
then
hash=${utxo%%#*}
idx=${utxo#*#}
utxo_balance=$(jq -r '.value.lovelace' <<< "${values}")
total_balance=$((${total_balance}+${utxo_balance}))
echo "TxHash: ${hash}#${idx}"
echo "UTXO Balance: ${utxo_balance} Lovelace"
tx_in="${tx_in} --tx-in ${hash}#${idx}"
fi
done <<< "$(jq -r 'keys[]' <<< "${utxo_json}")"
echo
echo "Total available balance: ${total_balance} Lovelace"
echo "Final --tx-in string:${tx_in}" - To build a draft transaction for calculating the transaction fee, type:
cardano-cli conway transaction build-raw \
${tx_in} \
--tx-out $(cat $NODE_HOME/payment.addr)+$(( ${total_balance} - 200000 )) \
--invalid-hereafter $(( ${currentSlot} + 10000 )) \
--fee 200000 \
--certificate-file $NODE_HOME/pool.dereg \
--out-file $NODE_HOME/tx.tmp - To calculate the fee for the transaction, type:
fee=$(cardano-cli conway transaction calculate-min-fee --output-json \
--tx-body-file $NODE_HOME/tx.tmp \
--witness-count 2 \
--byron-witness-count 0 \
--protocol-params-file $NODE_HOME/params.json | jq -r '.fee')
echo "Fee: ${fee}" - To calculate change from the transaction, type:
txOut=$(( ${total_balance} - ${fee} ))
echo "Change: ${txOut}" - To build the transaction, type:
cardano-cli conway transaction build-raw \
${tx_in} \
--tx-out $(cat $NODE_HOME/payment.addr)+${txOut} \
--invalid-hereafter $(( ${currentSlot} + 10000 )) \
--fee ${fee} \
--certificate-file $NODE_HOME/pool.dereg \
--out-file $NODE_HOME/tx.raw - Copy the
tx.rawfile that you created in step 10 to the$NODE_HOMEfolder on your air-gapped, offline computer, and then using a terminal window type the following commands to sign the transaction:cd $NODE_HOME
cardano-cli conway transaction sign \
--tx-body-file tx.raw \
--signing-key-file payment.skey \
--signing-key-file $HOME/cold-keys/node.skey \
--mainnet \
--out-file tx.signed - Copy the
tx.signedfile that you created in step 11 to the$NODE_HOMEfolder on the block-producing node, and then using a terminal window type the following command to submit the transaction to the network:cardano-cli conway transaction submit \
--tx-file $NODE_HOME/tx.signed \
--mainnet
After submitting the stake pool stake pool deregistration certificate to the network, if you decide that you no longer want to deregister the stake pool, following the procedure for Registering a Stake Pool prior to the beginning of the <EpochToRetire> that you specified overrides the deregistration certificate.
To verify that the stake pool retired successfully:
- Wait until the
<EpochToRetire>that you specified using the stake pool deregistration certificate begins. - Using a terminal window on the computer that you designated as the block-producing node in the configuration for the retired stake pool, when the local copy of the Cardano blockchain ledger is fully synchronized with the network type the following commands. If the stake pool retired successfully, then the
jqcommand returns an empty result set:cd $NODE_HOME
cardano-cli conway query ledger-state --mainnet > ledger-state.json
sudo systemctl stop cardano-node.service
jq -r '.stateBefore.esLState.delegationState.pstate.stakePoolParams."'"$(cat stakepoolid-hex.txt)"'" // empty' ledger-state.json
sudo systemctl start cardano-node.serviceNote

Querying the ledger state may take a few minutes to complete.
OR Using a blockchain explorer, verify that the pool retired. - To verify that the stake address registered as the reward account for the retired stake pool received the pool deposit refund, follow the procedure for Checking Stake Pool Rewards.
- If the reward account does not delegate votes, then complete the procedure for Delegating to a Representative.
- Follow the procedure for Claiming Stake Pool Rewards.
- As needed, follow the procedure for Sending Funds to another wallet.
Challenge | To receive the deposit for Registering a Stake Address, after receiving the stake pool deposit refund, deregister the stake address registered as the reward account for the retired stake pool. |
