English
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.
For a general discussion on creating transactions, see the topic Building and Signing Transactions in the official Cardano Testnet documentation.
To register a stake address on the blockchain:
Create a certificate, stake.cert, using the stake.vkey
air-gapped offline machine
1
cardano-cli stake-address registration-certificate \
2
--stake-verification-key-file stake.vkey \
3
--out-file stake.cert
Copied!
Copy stake.cert to your hot environment.
You need to find the tip of the blockchain to set the invalid-hereafter parameter properly.
block producer node
1
currentSlot=$(cardano-cli query tip --mainnet | jq -r '.slot')
2
echo Current Slot: $currentSlot
Copied!
Find your balance and UTXOs.
block producer node
1
cardano-cli query utxo \
2
--address $(cat payment.addr) \
3
--mainnet > fullUtxo.out
4
5
tail -n +3 fullUtxo.out | sort -k3 -nr > balance.out
6
7
cat balance.out
8
9
tx_in=""
10
total_balance=0
11
while read -r utxo; do
12
in_addr=$(awk '{ print $1 }' <<< "${utxo}")
13
idx=$(awk '{ print $2 }' <<< "${utxo}")
14
utxo_balance=$(awk '{ print $3 }' <<< "${utxo}")
15
total_balance=$((${total_balance}+${utxo_balance}))
16
echo TxHash: ${in_addr}#${idx}
17
echo ADA: ${utxo_balance}
18
tx_in="${tx_in} --tx-in ${in_addr}#${idx}"
19
done < balance.out
20
txcnt=$(cat balance.out | wc -l)
21
echo Total ADA balance: ${total_balance}
22
echo Number of UTXOs: ${txcnt}
Copied!
Find the amount of the deposit required to register a stake address.
block producer node
1
stakeAddressDeposit=$(cat $NODE_HOME/params.json | jq -r '.stakeAddressDeposit')
2
echo stakeAddressDeposit : $stakeAddressDeposit
Copied!
Registering a stake address requires a deposit of 2000000 lovelace.
Run the build-raw transaction command
The invalid-hereafter value must be greater than the current tip. In this example, we use current slot + 10000.
block producer node
1
cardano-cli transaction build-raw \
2
${tx_in} \
3
--tx-out $(cat payment.addr)+0 \
4
--invalid-hereafter $(( ${currentSlot} + 10000)) \
5
--fee 0 \
6
--out-file tx.tmp \
7
--certificate stake.cert
Copied!
Calculate the current minimum fee:
block producer node
1
fee=$(cardano-cli transaction calculate-min-fee \
2
--tx-body-file tx.tmp \
3
--tx-in-count ${txcnt} \
4
--tx-out-count 1 \
5
--mainnet \
6
--witness-count 2 \
7
--byron-witness-count 0 \
8
--protocol-params-file params.json | awk '{ print $1 }')
9
echo fee: $fee
Copied!
When calculating the fee for a transaction, the --witness-count option indicates the number of keys signing the transaction. You must sign a transaction submitting a stake address registration certificate to the blockchain using the secret—private—key for the payment address spending the input, as well as the secret key for the stake address to register.
When creating the transaction, ensure that the funds the input contains are greater than the total of the transaction fee and stake address deposit. If funds are insufficient, then the transaction fails.
Calculate your change output.
block producer node
1
txOut=$((${total_balance}-${stakeAddressDeposit}-${fee}))
2
echo Change Output: ${txOut}
Copied!
Build your transaction which will register your stake address.
block producer node
1
cardano-cli transaction build-raw \
2
${tx_in} \
3
--tx-out $(cat payment.addr)+${txOut} \
4
--invalid-hereafter $(( ${currentSlot} + 10000)) \
5
--fee ${fee} \
6
--certificate-file stake.cert \
7
--out-file tx.raw
Copied!
Copy tx.raw to your cold environment.
Sign the transaction with both the payment and stake secret keys.
air-gapped offline machine
1
cardano-cli transaction sign \
2
--tx-body-file tx.raw \
3
--signing-key-file payment.skey \
4
--signing-key-file stake.skey \
5
--mainnet \
6
--out-file tx.signed
Copied!
Copy tx.signed to your hot environment.
Send the signed transaction.
block producer node
1
cardano-cli transaction submit \
2
--tx-file tx.signed \
3
--mainnet
Copied!
Copy link