
1 Epoc = 5 days
1st Reward = after 3 Epoch(15 days)
after that every Epoc(5 days)
Ref : Cardano telegram channel
cardano
1 Epoc = 5 days
1st Reward = after 3 Epoch(15 days)
after that every Epoc(5 days)
Ref : Cardano telegram channel
cardano-cli stake-pool metadata-hash --pool-metadata-file poolMetaData.json > poolMetaDataHash.txt
cardano-cli stake-pool registration-certificate \
--cold-verification-key-file $HOME/cold-keys/node.vkey \
--vrf-verification-key-file vrf.vkey \
--pool-pledge 200000000000 \
--pool-cost 340000000 \
--pool-margin 0.02 \
--pool-reward-account-verification-key-file stake.vkey \
--pool-owner-stake-verification-key-file stake.vkey \
--testnet-magic 1097911063 \
--single-host-pool-relay relaynode1.cardano-devops.tk \
--pool-relay-port 6000 \
--metadata-url https://cardano-devops.tk/poolMetaData.json \
--metadata-hash $(cat poolMetaDataHash.txt) \
--out-file pool.cert
cardano-cli stake-address delegation-certificate \
--stake-verification-key-file stake.vkey \
--cold-verification-key-file $HOME/cold-keys/node.vkey \
--out-file deleg.cert
currentSlot=$(cardano-cli query tip --testnet-magic 1097911063 | jq -r '.slotNo')
echo Current Slot: $currentSlot
cardano-cli query utxo \
--address $(cat payment.addr) \
--mary-era \
--testnet-magic 1097911063 > 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
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}"
done < balance.out
txcnt=$(cat balance.out | wc -l)
echo Total ADA balance: ${total_balance}
echo Number of UTXOs: ${txcnt}
#Total ADA balance: 3396153590
#TxHash: d6aa6a151026961f86f1ef9b2e0df53cd6491f8683ff3e053d23687f245bad13#0
#Number of UTXOs: 1
cardano-cli transaction build-raw \
${tx_in} \
--tx-out $(cat payment.addr)+${total_balance} \
--invalid-hereafter $(( ${currentSlot} + 10000)) \
--fee 0 \
--certificate-file pool.cert \
--certificate-file deleg.cert \
--mary-era \
--out-file tx.tmp
fee=$(cardano-cli transaction calculate-min-fee \
--tx-body-file tx.tmp \
--tx-in-count ${txcnt} \
--tx-out-count 1 \
--testnet-magic 1097911063 \
--witness-count 3 \
--byron-witness-count 0 \
--protocol-params-file params.json | awk '{ print $1 }')
echo fee: $fee
#fee: 198809
txOut=$((${total_balance}-${fee}))
echo txOut: ${txOut}
#3395954781
cardano-cli transaction build-raw \
${tx_in} \
--tx-out $(cat payment.addr)+${txOut} \
--invalid-hereafter $(( ${currentSlot} + 10000)) \
--fee ${fee} \
--certificate-file pool.cert \
--certificate-file deleg.cert \
--mary-era \
--out-file tx.raw
cardano-cli transaction sign \
--tx-body-file tx.raw \
--signing-key-file payment.skey \
--signing-key-file $HOME/cold-keys/node.skey \
--signing-key-file stake.skey \
--testnet-magic 1097911063 \
--out-file tx.signed
cardano-cli transaction submit \
--tx-file tx.signed \
--testnet-magic 1097911063
cardano-cli query ledger-state --testnet-magic 1097911063 --mary-era --out-file ledger-state.json
#cardano #ada
Credit : EveryBlock.Studio
This will reclaim the 2 ADA deposit
cardano-cli query utxo --address $(cat payment.addr) --allegra-era --testnet-magic 1097911063
cardano-cli shelley query protocol-parameters \
--testnet-magic 1097911063 \
--allegra-era \
--out-file protocol.json
cardano-cli shelley stake-address deregistration-certificate \
--stake-verification-key-file stake.vkey \
--out-file destake.cert
cardano-cli shelley transaction build-raw \
--tx-in 6ac2a8ea2a8f949e22539ed405961e0bce409e461bcb752b3baaed9b3e06971f#0 \
--tx-out $(cat payment.addr)+0 \
--ttl 0 \
--fee 0 \
--out-file tx.raw \
--certificate-file destake.cert
cardano-cli shelley transaction calculate-min-fee \
--tx-body-file tx.raw \
--tx-in-count 1 \
--tx-out-count 1 \
--witness-count 1 \
--byron-witness-count 0 \
--testnet-magic 1097911063 \
--protocol-params-file protocol.json
fee: 172761
2896701265 - 172761 + 2000000 = 2898528504
currentSlot=$(cardano-cli query tip --testnet-magic 1097911063 | jq -r '.slotNo')
echo Current Slot: $currentSlot
cardano-cli shelley transaction build-raw \
--tx-in 6ac2a8ea2a8f949e22539ed405961e0bce409e461bcb752b3baaed9b3e06971f#0 \
--tx-out $(cat payment.addr)+2898528504 \
--ttl $(($currentSlot+1000)) \
--fee 172761 \
--out-file tx.raw \
--certificate-file destake.cert
cardano-cli shelley transaction sign \
--tx-body-file tx.raw \
--signing-key-file payment.skey \
--signing-key-file stake.skey \
--testnet-magic 1097911063 \
--out-file tx.signed
cardano-cli shelley transaction submit \
--tx-file tx.signed \
--testnet-magic 1097911063
Reclaim :
White paper: 3.10.2 Deposits
https://hydra.iohk.io/build/3744897/download/1/delegation_design_spec.pdf
Register :
https://docs.cardano.org/projects/cardano-node/en/latest/stake-pool-operations/register_key.html
cardano-node.yml
version: '3'
services:
jenkins:
image: koolwith/cardano-node
user: root:root
restart: always
container_name: cardano-node1
environment:
TZ: "Asia/Kolkata"
volumes:
- /opt//cardano-my-node:/root/cardano-my-node
ports:
- 6000:6000
cardano-node.Dockerfile
docker build -t cardano-node -f cardano-node.Dockerfile .
FROM debian:stable-slim as base
RUN apt-get update -y
RUN apt-get install git jq bc make rsync htop curl build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ wget libncursesw5 libtool autoconf -y
RUN mkdir $HOME/git \
&& cd $HOME/git \
&& git clone https://github.com/input-output-hk/libsodium \
&& cd libsodium \
&& git checkout 66f017f1 \
&& ./autogen.sh \
&& ./configure \
&& make \
&& make install
RUN cd \
&& wget https://downloads.haskell.org/~cabal/cabal-install-3.2.0.0/cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz \
&& tar -xf cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz \
&& rm cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz cabal.sig \
&& mkdir -p $HOME/.local/bin \
&& mv cabal $HOME/.local/bin/
RUN wget https://downloads.haskell.org/ghc/8.10.2/ghc-8.10.2-x86_64-deb9-linux.tar.xz \
&& tar -xf ghc-8.10.2-x86_64-deb9-linux.tar.xz \
&& rm ghc-8.10.2-x86_64-deb9-linux.tar.xz \
&& cd ghc-8.10.2 \
&& ./configure \
&& make install
RUN echo PATH="$HOME/.local/bin:$PATH" >> $HOME/.bashrc \
&& echo export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" >> $HOME/.bashrc \
&& echo export NODE_HOME=$HOME/cardano-my-node >> $HOME/.bashrc \
&& echo export NODE_CONFIG=mainnet>> $HOME/.bashrc \
&& echo export NODE_BUILD_NUM="$(curl https://hydra.iohk.io/job/Cardano/iohk-nix/cardano-deployment/latest-finished/download/1/index.html | grep -e "build" | sed 's/.*build\/\([0-9]*\)\/download.*/\1/g')" >> $HOME/.bashrc \
&& /bin/bash -c "source $HOME/.bashrc" \
&& mv $HOME/.local/bin/* /usr/local/bin/
RUN cabal update
RUN cd $HOME/git \
&& git clone https://github.com/input-output-hk/cardano-node.git \
&& cd cardano-node \
&& git fetch --all --recurse-submodules --tags \
&& git checkout tags/1.24.2
RUN cd $HOME/git/cardano-node \
&& export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" \
&& export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" \
&& cabal configure -O0 -w ghc-8.10.2 \
&& echo -e "package cardano-crypto-praos\n flags: -external-libsodium-vrf" > cabal.project.local \
&& sed -i $HOME/.cabal/config -e "s/overwrite-policy:/overwrite-policy: always/g" \
&& rm -rf $HOME/git/cardano-node/dist-newstyle/build/x86_64-linux/ghc-8.10.2 \
&& cabal build cardano-cli cardano-node \
&& cp $(find $HOME/git/cardano-node/dist-newstyle/build -type f -name "cardano-cli") /usr/local/bin/cardano-cli \
&& cp $(find $HOME/git/cardano-node/dist-newstyle/build -type f -name "cardano-node") /usr/local/bin/cardano-node
This article is copy of https://www.beaver-stake-pool.net/post/what-does-a-cardano-stake-pool-do
Simple put, a Cardano Stake Pool is a participant in the Proof-of-Stake consensus algorithm, Ouroboros.
During the Shelley phase, the Cardano network utilizes Ouroboros Praos. A stake pool’s main functions are:
Figure 1 below illustrates the general steps that a stake pool goes through to create a block.
Figure 1: How a Stake Pool Forges Blocks
Since a stake pool is checking for slot leadership every second, it is imperative that stake pools have 100% up-time to ensure they don’t miss being elected slot leader.
The Nonce value used in the VRF is used as a seeding value for random number generation. It is created by hashing the first 2/3s of the VRF outputs from the previous epoch’s blocks.
If a stake pool is not forging blocks, it still plays a role by verifying blocks and confirming transactions. Figure 2 illustrates how blocks are verified while the stake pool is waiting to be a slot leader.
Figure 2: How a stake pool verifies incoming blocks
An interesting property of Ouroboros Praos is that each stake pool independently tries to determine whether or not they are the slot leader with the VRF. The slot leadership schedule is not known in advance and pools will only know who a slot leader was when a block is received and verified.
This also means that two or more stake pools could determine themselves as the slot leader for a single slot. This is what’s called a slot battle. Slot battles are now resolved by the VRF. Whichever block has a lower VRF output value is determined to be the winner of that slot.
The cardano-node code developed by IOHK performs all these actions after a stake pool owner has configured the program to operate for their own pool(s).
For more details on Ouroboros Praos:
cardano-cli query ledger-state --testnet-magic 1097911063 --allegra-era
#Get specific stakepool details
cardano-cli query ledger-state --testnet-magic 1097911063 --allegra-era | grep -C 30 $(cat stakepoolid.txt)
payment2.addr = TO address (addr_test1qqr585tvlc7ylnqvz8pyqwauzrdu0mxag3m7q56grgmgu7sxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flknswgndm3)
payment.addr = FROM address(addr_test1qzvvw5j2636y3r0cg3spu94htzjxupmt2hxld5gxzsp873lpqqmdlvg6k2sfdnzjz8q3pr3q8meydx05q4cacmnzxxesawnv76)
#Draft transaction
cardano-cli shelley transaction build-raw \
--tx-in 173dcc8ce28c8d6c3900363c8c3a18f0dcdc953f1f108d1acf99bbfc66f99d9d#0 \
--tx-out $(cat payment2.addr)+0 \
--tx-out $(cat payment.addr)+0 \
--ttl 0 \
--fee 0 \
--out-file tx.draft
#Minimum fee
cardano-cli shelley transaction calculate-min-fee \
--tx-in-count 1 \
--tx-out-count 2 \
--tx-body-file tx.draft \
--testnet-magic 1097911063 \
--witness-count 3 \
--protocol-params-file protocol.json
minimum fee : 189481
#Calculation
497452809 – 100000000 – 189481 = 397263328
payment.addr – payment2.addr – fee = 397263328
#Get updated slot
currentSlot=$(cardano-cli query tip --testnet-magic 1097911063 | jq -r '.slotNo')
echo Current Slot: $currentSlot
updated_currentSlot=$(($currentSlot+1000))
echo Updated Slot: $updated_currentSlot
#Build raw transaction
cardano-cli shelley transaction build-raw \
--tx-in 173dcc8ce28c8d6c3900363c8c3a18f0dcdc953f1f108d1acf99bbfc66f99d9d#0 \
--tx-out $(cat payment2.addr)+100000000 \
--tx-out $(cat payment.addr)+397263328 \
--ttl 14949695 \
--fee 189481 \
--out-file tx.raw
#Sign transaction
cardano-cli shelley transaction sign \
--tx-body-file tx.raw \
--signing-key-file payment.skey \
--testnet-magic 1097911063 \
--out-file tx.signed
#Submit transaction
cardano-cli shelley transaction submit \
--tx-file tx.signed \
--testnet-magic 1097911063
root@core:~/cardano-my-node# cat protocol.json | grep minUTxOValue
“minUTxOValue“: 1000000,
Shelley command failed: transaction submit Error: Error while submitting tx: ApplyTxError [LedgerFailure (UtxowFailure (UtxoFailure (OutputTooSmallUTxO [(Addr Mainnet (KeyHashObj (KeyHash “6ccf7afbb2f916c52aa01eeffaa71b500d903ef2421c9b40343a5145”)) (StakeRefBase (KeyHashObj (KeyHash “61ffb9726ac8436bdecfe9b94b9f18d51ce26672452808019212cfdd”))),Coin 472257)])))]
#Current EPOC
cat testnet-shelley-genesis.json | grep epoch
#"epochLength": 432000
cardano-cli shelley query tip --testnet-magic 1097911063 | grep slotNo
#"slotNo": 14711760
expr 14711760 / 432000
#34
#34+1 = earliest epoch for retirement
cardano-cli shelley query protocol-parameters \
--testnet-magic 1097911063 \
--allegra-era \
--out-file protocol.json
cat protocol.json | grep eMax
#"eMax": 18
#Create deregistration certificate
cardano-cli shelley stake-pool deregistration-certificate \
--cold-verification-key-file node.vkey \
--epoch 35 \
--out-file pool.deregistration
#Draft the transaction
cardano-cli shelley query utxo \
--address $(cat payment.addr) \
--testnet-magic 1097911063 \
--allegra-era
cardano-cli shelley transaction build-raw \
--tx-in 173dcc8ce28c8d6c3900363c8c3a18f0dcdc953f1f108d1acf99bbfc66f99d9d#0 \
--tx-out $(cat payment.addr)+0 \
--ttl 0 \
--fee 0 \
--out-file tx.draft \
--certificate-file pool.deregistration
#Calculate the fees
cardano-cli shelley transaction calculate-min-fee \
--tx-body-file tx.draft \
--tx-in-count 1 \
--tx-out-count 1 \
--witness-count 1 \
--byron-witness-count 0 \
--testnet-magic 1097911063 \
--protocol-params-file protocol.json
#172761
expr 497452809 - 172761 = 497280048
#Build, sign and submit the transaction
#TTL
currentSlot=$(cardano-cli query tip --testnet-magic 1097911063 | jq -r '.slotNo')
echo Current Slot: $currentSlot
updated_currentSlot=$(($currentSlot+10000))
echo Updated Slot: $updated_currentSlot
#14721760
cardano-cli shelley transaction build-raw \
--tx-in 173dcc8ce28c8d6c3900363c8c3a18f0dcdc953f1f108d1acf99bbfc66f99d9d#0 \
--tx-out $(cat payment.addr)+497280048 \
--ttl 14721760 \
--fee 172761 \
--out-file tx.raw \
--certificate-file pool.deregistration
#sign
cardano-cli shelley transaction sign \
--tx-body-file tx.raw \
--signing-key-file payment.skey \
--signing-key-file node.skey \
--testnet-magic 1097911063 \
--out-file tx.signed
#submit
cardano-cli shelley transaction submit \
--tx-file tx.signed \
--testnet-magic 1097911063
#stackpool status:
cardano-cli stake-pool id --cold-verification-key-file $HOME/cold-keys/node.vkey --output-format hex > stakepoolid.txt
cat stakepoolid.txt
cardano-cli query ledger-state --testnet-magic 1097911063 --allegra-era | grep -C 20 $(cat stakepoolid.txt)
Check status
cardano-cli query ledger-state --testnet-magic 1097911063 --allegra-era --out-file ledger-state.json
jq -r '.esLState._delegationState._pstate._pParams."'"$(cat stakepoolid.txt)"'" // empty' ledger-state.json
Reward status:
cardano-cli query stake-address-info \
--testnet-magic 1097911063 \
--allegra-era \
--address $(cat stake.addr) | jq -r ".[0].rewardAccountBalance"
Refrences:
– https://www.coincashew.com/coins/overview-ada/guide-how-to-build-a-haskell-stakepool-node#19-retire-your-stake-pool
– https://docs.cardano.org/projects/cardano-node/en/latest/stake-pool-operations/retire_stakepool.html