Categories
Uncategorized

Create payment address cardano


cardano-cli address key-gen \
    --verification-key-file payment.vkey \
    --signing-key-file payment.skey



cardano-cli stake-address key-gen \
    --verification-key-file stake.vkey \
    --signing-key-file stake.skey




cardano-cli stake-address build \
    --stake-verification-key-file stake.vkey \
    --out-file stake.addr \
    --testnet-magic 1



cardano-cli address build \
    --payment-verification-key-file payment.vkey \
    --stake-verification-key-file stake.vkey \
    --out-file payment.addr \
    --testnet-magic 1


cardano-cli query utxo \
    --address $(cat payment.addr) \
    --testnet-magic 1

https://www.coincashew.com/coins/overview-ada/guide-how-to-build-a-haskell-stakepool-node/part-iii-operation/setting-up-payment-and-stake-keys

Categories
Uncategorized

Cardano testnet setup with docker-compose

version: "3.5"

services:
  cardano-node:
    image: inputoutput/cardano-node:1.35.0
    environment:
      NETWORK:
      CARDANO_NODE_SOCKET_PATH: "/ipc/node.socket"
    volumes:
      - node-${NETWORK}-db:/data
      - node-ipc:/ipc
    restart: on-failure
    logging:
      driver: "json-file"
      options:
        compress: "true"
        max-file: "10"
        max-size: "50m"

  cardano-wallet:
    image: inputoutput/cardano-wallet:2022.7.1
    volumes:
      - wallet-${NETWORK}-db:/wallet-db
      - node-ipc:/ipc
    ports:
      - 8090:8090
    entrypoint: []
    command: bash -c "
        ([[ $$NETWORK == \"mainnet\" ]] && $$CMD --mainnet) ||
        ($$CMD --testnet /config/${NETWORK}/genesis-byron.json)
      "
    environment:
      CMD: "cardano-wallet serve --node-socket /ipc/node.socket --database /wallet-db --listen-address 0.0.0.0"
      NETWORK:
    restart: on-failure
    logging:
      driver: "json-file"
      options:
        compress: "true"
        max-file: "10"
        max-size: "50m"


  cardano-submit-api:
    image: inputoutput/cardano-submit-api:1.35.0
    environment:
      - NETWORK=${NETWORK:-mainnet}
    depends_on:
      - cardano-node
    volumes:
      - node-ipc:/node-ipc
    ports:
      - 8091:8090
    restart: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"

volumes:
  node-mainnet-db:
  node-testnet-db:
  node-alonzo-purple-db:
  wallet-mainnet-db:
  wallet-testnet-db:
  wallet-alonzo-purple-db:
  node-ipc:
  node-config:

source : https://github.com/input-output-hk/cardano-wallet/blob/master/docker-compose.yml

Start testnet :

NETWORK=testnet docker compose -f cardano-compose.yml up -d

Start mainnet :

NETWORK=mainnet docker compose -f cardano-compose.yml up -d

To access cardano-cli set CARDANO_NODE_SOCKET_PATH

export CARDANO_NODE_SOCKET_PATH=/var/lib/docker/volumes/root_node-ipc/_data/node.socket
Categories
Uncategorized

Create NFT in cardano-testnet

Note : Assets name should in base16

https://forum.cardano.org/t/error-while-minting-nft-transaction-using-full-node/84784

Read the docs carefully : https://developers.cardano.org/docs/native-tokens/minting-nfts

Categories
Uncategorized

Create metadata transcation in cardano testnet

cat metadata.json
{    
    "1": {"data": "hello cardano"}
}


cardano-cli query utxo --testnet-magic 1097911063 --address $(cat payment.addr)

999825831

cardano-cli transaction build-raw \
--tx-in d80a355f11d26025802a74f614c06f3a1eb347d9be489fcf2048989f9ce34bed#0 \
--tx-out $(cat payment.addr)+0 \
--metadata-json-file metadata.json \
--fee 0 \
--out-file tx.draft


cardano-cli query protocol-parameters \
    --testnet-magic 1097911063 \
    --out-file protocol.json


cardano-cli 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

fee : 175005

999825831-175005 = 999650826
    

cardano-cli transaction build-raw \
--tx-in d80a355f11d26025802a74f614c06f3a1eb347d9be489fcf2048989f9ce34bed#0 \
--tx-out $(cat payment.addr)+999650826 \
--metadata-json-file metadata.json \
--fee 175005 \
--out-file tx.draft

cardano-cli transaction sign \
--tx-body-file tx.draft \
--signing-key-file payment.skey \
--testnet-magic 1097911063 \
--out-file tx.signed


cardano-cli transaction submit \
--tx-file tx.signed \
--testnet-magic 1097911063

More = https://developers.cardano.org/docs/transaction-metadata/how-to-create-a-metadata-transaction-cli/

https://github.com/input-output-hk/cardano-node/blob/master/doc/stake-pool-operations/simple_transaction.md

Categories
cardano

cardano reward

1 Epoc = 5 days

1st Reward = after 3 Epoch(15 days)
after that every Epoc(5 days)

Ref : Cardano telegram channel

Categories
cardano

Cardano Testnet- Changing the pledge fee margin etc

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
Categories
cardano

Math behind Cardano logo

#cardano #ada

Categories
cardano Uncategorized

Cardano epoch rewards come from ?

Credit : EveryBlock.Studio

Categories
cardano

De-Register stake address Cardano – Testnet

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 :

https://explorer.cardano-testnet.iohkdev.io/en/transaction?id=5f15dcb0d82f0440269cd68fb313dfa6428f544eb5154941967e25436ba8cb3a

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

Categories
cardano Uncategorized

cardano node Dockerfile

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