Registering Your Stake Address
Pledge is the stake that you delegate to your own pool. Using a transaction, you must register on the blockchain the stake address associated with a payment address containing funds that you want to pledge.
To register a stake address on the blockchain:
Create a certificate, stake.cert, using the stake.vkey
cardano-cli conway stake-address registration-certificate \
--stake-verification-key-file stake.vkey \
--key-reg-deposit-amt 2000000 \
--out-file stake.certCopy stake.cert to your hot environment.
You need to find the tip of the blockchain to set the invalid-hereafter parameter properly.
currentSlot=$(cardano-cli conway query tip --mainnet | jq -r '.slot')
echo Current Slot: $currentSlotRetrieve the UTXOs available for your payment address and calculate the balance.
# Retrieve the list of UTXOs available for your payment address
utxo_json=$(cardano-cli conway query utxo --address $(cat payment.addr) --mainnet)
# Initialize variables
tx_in=""
total_balance=0
txcnt=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 "ADA: ${utxo_balance}"
tx_in="${tx_in} --tx-in ${hash}#${idx}"
txcnt=$((txcnt + 1))
fi
done <<< "$(jq -r 'keys[]' <<< "${utxo_json}")"
echo
echo "Total available ADA balance: ${total_balance}"
echo "Number of UTXOs: ${txcnt}"
echo "Final --tx-in string:${tx_in}"Find the amount of the deposit required to register a stake address.
Run the build-raw transaction command
Calculate the current minimum fee:
Calculate your change output.
Build your transaction which will register your stake address.
Copy tx.raw to your cold environment.
Sign the transaction with both the payment and stake secret keys.
Copy tx.signed to your hot environment.
Send the signed transaction.
Last updated