How to get current epoch and current slot from cardano-cli

Hello all,
I’m following the CoinCashew guide for setting up Stake Pool. According to CoinCashew guide the slot# must equal the slot (Poin 9):

Before continuing, your node must be fully synchronized to the blockchain. Otherwise, you won’t calculate the latest KES period. Your node is synchronized when the epoch and slot# is equal to that found on a block explorer such as

But I’m getting very high (weird) number compared to the

[cardano-producer@uranus ~]$ cardano-cli query tip --mainnet | jq -r ‘.slotNo’

Looking through the RTView, everything seems to match

How can I get current epoch and current slot from the cardano-cli (to compare it to the And what is the slotNo from the cardano-cli query tip --mainnet? Are the slotNo from cardano-cli and Slot from the different things?


I’m using the latest version of cardano-node:

[cardano@uranus ~]$ cardano-cli --version
cardano-cli 1.25.1 - linux-x86_64 - ghc-8.10
git rev 9a7331cce5e8bc0ea9c6bfa1c28773f4c5a7000f

Slot No. & Slot in Epoch are different thing by my understandings, here are the values from the RTView:

Slot No:

Slot in Epoch:

Pooltool (slot per Epoch)

So, the code given by CoinCashew is showing SlotNo (not Slot per Epoch):
slotNo=(cardano-cli query tip --mainnet | jq -r '.slotNo') echo slotNo: {slotNo}

But where to see the slotNo from pooltool ?

Turns out nixos isn’t supported so I have it up on ubuntu now. That makes sense on slot number vs slot in epoch.

I was able to stand everything up on latest code ubuntu and gliveview matches, however the coincashew command does not match. I have a feeling coincashew command is incorrect but would need someone more knowledgeable to confirm.

I was fighting build issues on nixos and once stood up there when seeing the command output thought i may have made a mistake during build time. Now going through ubuntu install including glive I feel more confident that glive is gathering the correct data.

The guild script gets the value here: //0,
reference: guild-operators/env at 6c5cec520bdced0d9b5b455968c400f67a5bf281 · cardano-community/guild-operators · GitHub

looking now to see if there is a bug in the cardano-cli returning the slot in epoch in place of the slot number. it appears glive pulls the data from the node directly but im still unraveling the code in my brain to understand what could be happening between the cardano-cli output and gliveview.

run this api call from your node to see where glive gets the data:
curl -s -m 300 -H ‘Accept: application/json’ “” |python3 -m json.tool

curl -s -m 300 -H 'Accept: application/json' "" |python3 -m json.tool|grep -A 5 slot "slotInEpoch": { "int": { "type": "g", "val": 266961 } }, "slotNum": { "int": { "type": "g", "val": 23335761 } }, cardano-cli query tip --mainnet | jq -r ‘.slotNo’

After full sync I am still seeing a discrepancy of a few slot numbers.

I suspect something happened around this commit.

Ok I bashed a longer running test and now they return the same int from the EKG api and the cardano-cli. Seems non deterministic i am going to file a bug on the github page and see if there is a logical explanation.

the coin cashew command is showing the current slot no. since inception vs. pooltool showing the slot no within the epoch

there has been 43 epochs since the Shelley hard fork, when the slot no was 4,492,800. There are 432,000 slots per epoch. 43*432,000=18,576,000 + 4,492,800 = 23,068,800. the coin cashew command shows 23,348,602 which includes where we are in the current epoch (roughly 280,000).

looks like you are good to go :grinning:



Is there an explanation as to why the EKG api call to the node returns a different slotNo than the cardano-cli?

cardano-cli query tip --mainnet | jq -r ‘.slotNo’

the command is quering TIP so you are esentially getting information related to the block since inception (number ultimately based on where in the chain the node is sync’d). I’m not sure if there is a command just for the current epoch or if sites like are dividing by some value to get the intra epoch slot no.

1 Like

Thank you @KrakenStaking that helps a lot!