mkdir -p $HOME/srccd $HOME/srcgit clone https://github.com/input-output-hk/cardano-node.git
cd $HOME/src/cardano-nodegit fetch --all --recurse-submodules --tagsgit stashgit checkout tags/1.35.7
cabal configure --with-compiler=ghc-8.10.7
echo "package cardano-crypto-praos" >> cabal.project.localecho " flags: -external-libsodium-vrf" >> cabal.project.local
cabal cleancabal update
cabal build all
echo ;\$(find $HOME/src/cardano-node/dist-newstyle/build -type f -name "cardano-node") version ;\echo ;\$(find $HOME/src/cardano-node/dist-newstyle/build -type f -name "cardano-cli") version
sudo systemctl stop cardano-node
mkdir -p ~/.local/bincp -p "$(./scripts/bin-path.sh cardano-node)" ~/.local/bin/cp -p "$(./scripts/bin-path.sh cardano-cli)" ~/.local/bin/
echo ;\cardano-cli --version ;\echo ;\cardano-node version
cd $NODE_HOMEwget https://raw.githubusercontent.com/input-output-hk/cardano-node/master/configuration/cardano/mainnet-config.json# Change "TraceBlockFetchDecisions" to "true" to enable live view.sed -i mainnet-config.json \ -e "s/TraceBlockFetchDecisions\": false/TraceBlockFetchDecisions\": true/g"# Change Prometheus address so Monitoring relay node can scrape data from cardano-node.sed -i $NODE_HOME/mainnet-config.json -e "s/127.0.0.1/0.0.0.0/g"
sudo systemctl start cardano-node
cardano-cli query protocol-parameters \ --mainnet \ --out-file $NODE_HOME/params.json
scp -r -P SSH_port -i /path/to/id_rsa username@ip_of_node:.local/bin/cardano-cli /path/to/Downloads/folder
scp -r -P 1234 -i /Users/Charles/RSA/id_rsa charles@12.34.56.78:.local/bin/cardano-cli /Users/Charles/Downloads
sudo chmod +x $HOME/cardano/cardano-cli
cardano-cli --version
echo ;\echo β stakePoolDeposit: $(cat $NODE_HOME/params.json | jq -r '.stakePoolDeposit') ;\echo β minPoolCost: $(cat $NODE_HOME/params.json | jq -r '.minPoolCost') ;\echo β stakeAddressDeposit: $(cat $NODE_HOME/params.json | jq -r '.stakeAddressDeposit') ;\echo β currentSlot: $(cardano-cli query tip --mainnet | jq -r '.slot') ;\echo β currentBlock: $(cardano-cli query tip --mainnet | jq -r '.block')
cat $NODE_HOME/params.json ;\cardano-cli query tip --mainnet
kes_remaining=$(curl -s localhost:12798/metrics | grep cardano_node_metrics_remainingKESPeriods_int | awk '{print $2}') ;\slotsPerKESPeriod=$(cat $NODE_HOME/mainnet-shelley-genesis.json | jq -r '.slotsPerKESPeriod') ;\echo ;\echo β Days left: $((${kes_remaining} * ${slotsPerKESPeriod} / 86400))
cardano-cli text-view decode-cbor --in-file $NODE_HOME/pool-operation.cert | grep int | head -1
Output should look like this01 # int(0)
mv $NODE_HOME/kes.skey $NODE_HOME/kes-old-dont-use.skey ;\mv $NODE_HOME/pool-operation.cert $NODE_HOME/pool-operation-old-dont-use.cert
cat $NODE_HOME/kes.skey ;\cat $NODE_HOME/pool-operation.cert
Output should look like thiscat: /home/.../cardano/kes.skey: No such file or directorycat: /home/.../cardano/pool-operation.cert: No such file or directory
mv $HOME/cardano/cold-keys/cold-kes.vkey $HOME/cardano/cold-keys/cold-kes-old-dont-use.vkey ;\mv $HOME/cardano/kes.skey $HOME/cardano/kes-old-dont-use.skey ;\mv $HOME/cardano/pool-operation.cert $HOME/cardano/pool-operation-old-dont-use.cert
cat $HOME/cardano/kes.skey ;\cat $HOME/cardano/cold-keys/cold-kes.vkey ;\cat $HOME/cardano/pool-operation.cert
Output should look like thiscat: /home/.../cardano/kes.skey: No such file or directorycat: /home/.../cardano/cold-keys/cold-kes.vkey: No such file or directorycat: /home/.../cardano/pool-operation.cert: No such file or directory
slotsPerKESPeriod=$(cat $NODE_HOME/mainnet-shelley-genesis.json | jq -r '.slotsPerKESPeriod') ;\slotNo=$(cardano-cli query tip --mainnet | jq -r '.slot') ;\kesPeriod=$((${slotNo} / ${slotsPerKESPeriod})) ;\echo ;\echo β slotsPerKESPeriod: ${slotsPerKESPeriod} ;\echo β slotNo: ${slotNo} ;\echo β kesPeriod: ${kesPeriod}
cardano-cli node key-gen-KES \ --verification-key-file $HOME/cardano/cold-keys/cold-kes.vkey \ --signing-key-file $HOME/cardano/kes.skey
cardano-cli node issue-op-cert \ --kes-verification-key-file $HOME/cardano/cold-keys/cold-kes.vkey \ --cold-signing-key-file $HOME/cardano/cold-keys/cold-pool.skey \ --operational-certificate-issue-counter $HOME/cardano/cold-keys/cold-op-cert-issue.counter \ --kes-period kesPeriod \ --out-file $HOME/cardano/pool-operation.cert
ls -lh $NODE_HOME | grep 'pool-operation.cert\|kes.skey'
-rw------- 1 1.3K Mar 25 23:07 kes.skey-rwxrwxr-x 1 365 Mar 25 23:40 pool-operation.cert
cardano-cli text-view decode-cbor --in-file $NODE_HOME/pool-operation.cert | grep int | head -1
Output should look like this01 # int(1)
ls $NODE_HOME -l
Output should look like this-rw------- ....
cardano-cli node key-hash-VRF \ --verification-key-file $HOME/cardano/cold-keys/cold-vrf.vkey
sudo systemctl restart cardano-node
kes_remaining=$(curl -s localhost:12798/metrics | grep cardano_node_metrics_remainingKESPeriods_int | awk '{print $2}') ;\slotsPerKESPeriod=$(cat $NODE_HOME/mainnet-shelley-genesis.json | jq -r '.slotsPerKESPeriod') ;\echo ;\echo β Days left: $((${kes_remaining} * ${slotsPerKESPeriod} / 86400))
sudo ufw allow proto tcp from 1.2.3.4 to any port ${POOL_RELAY_PORT}
sudo ufw status numbered
Output should contain this line[ x] POOL_RELAY_PORT/tcp ALLOW IN NEW_RELAY_NODE_IP
sudo nano $NODE_HOME/mainnet-topology.json
{ "Producers": [ { "addr": "relay_1_IPv4", "port": ${POOL_RELAY_PORT}, "valency": 1  }, { "addr": "relay_2_IPv4", "port": ${POOL_RELAY_PORT}, "valency": 1  } ]}
sudo systemctl restart cardano-node
sudo nano /etc/prometheus/prometheus.yml
global: scrape_interval: 10s external_labels: monitor: 'codelab-monitor'scrape_configs: # Scrape data from cardano-node - job_name: 'cardano-node' static_configs: - targets: ['localhost:12798'] - targets: ['$(cat $NODE_HOME/bp-node-ip.txt):12798'] - targets: ['new_relay_ip:12798'] # Add more relay nodes here if needed # Scrape data from prometheus-node-exporter - job_name: 'node-exporter' static_configs: - targets: ['localhost:9100'] - targets: ['$(cat $NODE_HOME/bp-node-ip.txt):9100'] - targets: ['new_relay_ip:9100'] # Add more relay nodes here if needed
sudo systemctl restart prometheus
sudo systemctl status prometheus
Output should look like thisπ’ prometheus.service - Monitoring system and time series database Loaded: loaded (/lib/systemd/system/prometheus.service; enabled; vendor preset: enab> Active: active (running)
if [ ! -e $NODE_HOME/poolMetadata_VersionCount.txt ]then echo "1" > $NODE_HOME/poolMetadata_VersionCount.txtfi ;\poolMetadataVersion=$(cat $NODE_HOME/poolMetadata_VersionCount.txt) ;\poolMetadataVersion=$(($poolMetadataVersion + 1)) ;\echo $poolMetadataVersion > $NODE_HOME/poolMetadata_VersionCount.txt ;\echo ;\echo β Current Pool Metadata Version: $(tput bold)$poolMetadataVersion$(tput sgr0)
poolMetadataVersion=$(cat $NODE_HOME/poolMetadata_VersionCount.txt)cat > $NODE_HOME/poolMetadataVersion${poolMetadataVersion}.json << EOF{"name": "Cool Pool name","description": "Here's why you should stake with us","ticker": "3-5 CHARACTERS","homepage": "https://www.examplepooldomain.com Just leave blank if don't use","extended": "https://link/to/poolExtendedMetadata.json"}EOFecho ;\echo β File name: $(tput bold)poolMetadataVersion${poolMetadataVersion}.json$(tput sgr0) ;\echo β Content: ;\cat $NODE_HOME/poolMetadataVersion${poolMetadataVersion}.json
poolMetadataVersion=$(cat $NODE_HOME/poolMetadata_VersionCount.txt) ;\wget -O $NODE_HOME/poolMetadataVersion${poolMetadataVersion}.json https://git.io/abcde ;\echo ;\echo β File name: $(tput bold)poolMetadataVersion${poolMetadataVersion}.json$(tput sgr0) ;\echo β Content: ;\cat $NODE_HOME/poolMetadataVersion${poolMetadataVersion}.json
poolMetadataVersion=$(cat $NODE_HOME/poolMetadata_VersionCount.txt) ;\cardano-cli stake-pool metadata-hash \ --pool-metadata-file $NODE_HOME/poolMetadataVersion${poolMetadataVersion}.json > $NODE_HOME/poolMetadataHash.txt ;\echo ;\echo β Hash is: $(cat $NODE_HOME/poolMetadataHash.txt)
mv $NODE_HOME/pool-registration.cert $NODE_HOME/pool-registration-old.cert
mv $HOME/cardano/pool-registration.cert $HOME/cardano/pool-registration-old.cert ;\cardano-cli stake-pool registration-certificate \ --pool-pledge YOUR_PLEDGE_IN_LOVELACE \ --pool-cost 340000000 \ --pool-margin 0.01 \ --single-host-pool-relay relays.examplepooldomain.com \ --pool-relay-port 6000 \ --metadata-url https://link/to/poolMetadata.json \ \ \ --metadata-hash $(cat $HOME/cardano/poolMetadataHash.txt) \ --cold-verification-key-file $HOME/cardano/cold-keys/cold-pool.vkey \ --vrf-verification-key-file $HOME/cardano/cold-keys/cold-vrf.vkey \ --pool-reward-account-verification-key-file $HOME/cardano/cold-keys/cold-stake.vkey \ --pool-owner-stake-verification-key-file $HOME/cardano/cold-keys/cold-stake.vkey \ --mainnet \ --out-file $HOME/cardano/pool-registration.cert ;\echo ;\echo β pool-registration.cert content: ;\cat $HOME/cardano/pool-registration.cert
type: CertificateShelleydescription: Stake Pool Registration CertificatecborHex:885e22d5d63...
mv $NODE_HOME/tx.draft $NODE_HOME/tx-old.draft 2>/dev/null ;\mv $NODE_HOME/tx.raw $NODE_HOME/tx-old.raw 2>/dev/null ;\mv $NODE_HOME/tx.signed $NODE_HOME/tx-old.signed 2>/dev/null ;\cd $NODE_HOME ;\\cardano-cli query utxo \ --address $(cat $NODE_HOME/payment-with-stake.addr) \ --mainnet > fullUtxo.out ;\tail -n +3 fullUtxo.out | sort -k3 -nr > balance.out ;\tx_in="" ;\lovelace_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}") lovelace_total_balance=$((${lovelace_total_balance}+${utxo_balance})) tx_in="${tx_in} --tx-in ${in_addr}#${idx}"done < balance.out ;\tx_in_count=$(cat balance.out | wc -l) ;\currentSlot=$(cardano-cli query tip --mainnet | jq -r '.slot') ;\invalidHereafter=$((${currentSlot} + 10000)) ;\\echo ;\echo β
VERIFY THE INFORMATION BELOW: ;\echo β UTxOs List: ; \cat balance.out ; \echo β Total Lovelace balance: ${lovelace_total_balance} ;\echo β Number of UTxOs: ${tx_in_count} ;\echo β Transaction Input: ${tx_in} ;\echo β Current Slot: $currentSlot ;\echo β Transaction Invalid Hereafter: $invalidHereafter ;\\rm fullUtxo.out ;\rm balance.out
cardano-cli transaction build-raw \ ${tx_in} \ --tx-out $(cat $NODE_HOME/payment-with-stake.addr)+${lovelace_total_balance} \ --invalid-hereafter ${invalidHereafter} \ --fee 0 \ --certificate-file $NODE_HOME/pool-registration.cert \ --certificate-file $NODE_HOME/delegation.cert \ --out-file $NODE_HOME/tx.draft
fee=$(cardano-cli transaction calculate-min-fee \ --tx-body-file $NODE_HOME/tx.draft \ --tx-in-count ${tx_in_count} \ --tx-out-count 1 \ --witness-count 3 \ --byron-witness-count 0 \ --mainnet \ --protocol-params-file $NODE_HOME/params.json | awk '{ print $1 }') ;\tx_out_change=$(($lovelace_total_balance - $fee)) ;\tx_out_with_fee="$(cat $NODE_HOME/payment-with-stake.addr)+${tx_out_change}" ;\echo ;\echo β
VERIFY THE INFORMATION BELOW: ;\echo β fee: $fee ;\echo β Transaction Output Change: ${tx_out_change} ;\echo β Transaction Output WITH Fee: ${tx_out_with_fee}
cardano-cli transaction build-raw \ ${tx_in} \ --tx-out ${tx_out_with_fee} \ --invalid-hereafter ${invalidHereafter} \ --fee ${fee} \ --certificate-file $NODE_HOME/pool-registration.cert \ --certificate-file $NODE_HOME/delegation.cert \ --out-file $NODE_HOME/tx.raw
mv $HOME/cardano/tx.signed $HOME/cardano/tx-old.signed ;\cardano-cli transaction sign \ --tx-body-file $HOME/cardano/tx.raw \ --signing-key-file $HOME/cardano/cold-keys/cold-payment.skey \ --signing-key-file $HOME/cardano/cold-keys/cold-pool.skey \ --signing-key-file $HOME/cardano/cold-keys/cold-stake.skey \ --mainnet \ --out-file $HOME/cardano/tx.signed
cardano-cli transaction submit \--tx-file $NODE_HOME/tx.signed \--mainnet
cardano-cli query utxo --address $(cat $NODE_HOME/payment-with-stake.addr) --mainnet ;\echo β Expected total balance: ${tx_out_change}
reward_lovelace=$(cardano-cli query stake-address-info \ --mainnet \ --address $(cat $NODE_HOME/stake.addr) | jq -r ".[0].rewardAccountBalance") ;\echo ;\echo β Rewards in lovelace: $(tput bold)$reward_lovelace$(tput sgr0)
reward_recipient_address=$(cat payment-with-stake.addr) ;\echo ;\echo β Reward recipient address: $(tput bold)$reward_recipient_address$(tput sgr0)
mv $NODE_HOME/tx.draft $NODE_HOME/tx-old.draft 2>/dev/null ;\mv $NODE_HOME/tx.raw $NODE_HOME/tx-old.raw 2>/dev/null ;\mv $NODE_HOME/tx.signed $NODE_HOME/tx-old.signed 2>/dev/null ;\cd $NODE_HOME ;\\cardano-cli query utxo \ --address $reward_recipient_address \ --mainnet > fullUtxo.out ;\tail -n +3 fullUtxo.out | sort -k3 -nr > balance.out ;\tx_in="" ;\lovelace_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}") lovelace_total_balance=$((${lovelace_total_balance}+${utxo_balance})) tx_in="${tx_in} --tx-in ${in_addr}#${idx}"done < balance.out ;\tx_in_count=$(cat balance.out | wc -l) ;\currentSlot=$(cardano-cli query tip --mainnet | jq -r '.slot') ;\invalidHereafter=$((${currentSlot} + 10000)) ;\withdrawal_input=$(cat $NODE_HOME/stake.addr)+${reward_lovelace} ;\\echo ;\echo β
VERIFY THE INFORMATION BELOW: ;\echo β UTxOs List: ; \cat balance.out ; \echo β Total Lovelace balance: ${lovelace_total_balance} ;\echo β Number of UTxOs: ${tx_in_count} ;\echo β Transaction Input: ${tx_in} ;\echo β Current Slot: $currentSlot ;\echo β Transaction Invalid Hereafter: $invalidHereafter ;\echo β Withdrawal Input: $withdrawal_input ;\\rm fullUtxo.out ;\rm balance.out
cardano-cli transaction build-raw \ ${tx_in} \ --tx-out ${reward_recipient_address}+0 \ --invalid-hereafter ${invalidHereafter} \ --fee 0 \ --withdrawal ${withdrawal_input} \ --out-file $NODE_HOME/tx.draft
fee=$(cardano-cli transaction calculate-min-fee \ --tx-body-file $NODE_HOME/tx.draft \ --tx-in-count ${tx_in_count} \ --tx-out-count 1 \ --witness-count 2 \ --byron-witness-count 0 \ --mainnet \ --protocol-params-file $NODE_HOME/params.json | awk '{ print $1 }') ;\tx_out_change=$(($lovelace_total_balance - $fee + $reward_lovelace)) ;\tx_out_with_fee="${reward_recipient_address}+${tx_out_change}" ;\echo ;\echo β
VERIFY THE INFORMATION BELOW: ;\echo β fee: $fee ;\echo β Transaction Output Change: ${tx_out_change} ;\echo β Transaction Output WITH Fee: ${tx_out_with_fee}
cardano-cli transaction build-raw \ ${tx_in} \ --tx-out ${tx_out_with_fee} \ --invalid-hereafter ${invalidHereafter} \ --fee ${fee} \ --withdrawal ${withdrawal_input} \ --out-file $NODE_HOME/tx.raw
mv $HOME/cardano/tx.signed $HOME/cardano/tx-old.signed ;\cardano-cli transaction sign \ --tx-body-file $HOME/cardano/tx.raw \ --signing-key-file $HOME/cardano/cold-keys/cold-payment.skey \ --signing-key-file $HOME/cardano/cold-keys/cold-stake.skey \ --mainnet \ --out-file $HOME/cardano/tx.signed
cardano-cli transaction submit \--tx-file $NODE_HOME/tx.signed \--mainnet
cardano-cli query utxo --address ${reward_recipient_address} --mainnet ;\echo β Expected total balance: ${tx_out_change}
CNCLI_RELEASE_TAG=$(curl -s https://api.github.com/repos/AndrewWestberg/cncli/releases/latest | jq -r .tag_name)CNCLI_VERSION=$(echo ${CNCLI_RELEASE_TAG} | cut -c 2-)curl -sLJ https://github.com/AndrewWestberg/cncli/releases/download/${CNCLI_RELEASE_TAG}/cncli-${CNCLI_VERSION}-x86_64-unknown-linux-gnu.tar.gz -o /tmp/cncli-${CNCLI_VERSION}-x86_64-unknown-linux-gnu.tar.gz
sudo tar xzvf /tmp/cncli-${CNCLI_VERSION}-x86_64-unknown-linux-gnu.tar.gz -C /usr/local/bin/
command -v cncli
/usr/local/bin/cncli sync --host 0.0.0.0 --port 6000 --no-service
POOL_ID=$(cat $NODE_HOME/pool-id.txt)echo "POOL ID: $POOL_ID"SNAPSHOT=$(cardano-cli query stake-snapshot --stake-pool-id $POOL_ID --mainnet)
POOL_STAKE=$(jq .poolStakeMark <<< $SNAPSHOT)ACTIVE_STAKE=$(jq .activeStakeMark <<< $SNAPSHOT)/usr/local/bin/cncli leaderlog --pool-id $POOL_ID --pool-vrf-skey ${NODE_HOME}/vrf.skey --byron-genesis ${NODE_HOME}/mainnet-byron-genesis.json --shelley-genesis ${NODE_HOME}/mainnet-shelley-genesis.json --pool-stake $POOL_STAKE --active-stake $ACTIVE_STAKE --ledger-set next
POOL_STAKE=$(jq .poolStakeSet <<< $SNAPSHOT)ACTIVE_STAKE=$(jq .activeStakeSet <<< $SNAPSHOT)/usr/local/bin/cncli leaderlog --pool-id $POOL_ID --pool-vrf-skey ${NODE_HOME}/vrf.skey --byron-genesis ${NODE_HOME}/mainnet-byron-genesis.json --shelley-genesis ${NODE_HOME}/mainnet-shelley-genesis.json --pool-stake $POOL_STAKE --active-stake $ACTIVE_STAKE --ledger-set current
POOL_STAKE=$(jq .poolStakeGo <<< $SNAPSHOT)ACTIVE_STAKE=$(jq .activeStakeGo <<< $SNAPSHOT)/usr/local/bin/cncli leaderlog --pool-id $POOL_ID --pool-vrf-skey ${NODE_HOME}/vrf.skey --byron-genesis ${NODE_HOME}/mainnet-byron-genesis.json --shelley-genesis ${NODE_HOME}/mainnet-shelley-genesis.json --pool-stake $POOL_STAKE --active-stake $ACTIVE_STAKE --ledger-set prev