Trying to query slot and getting null in return

When I run this:
currentSlot=$(cardano-cli query tip --mainnet | jq -r ‘.slotNo’)
echo Current Slot: $currentSlot

When I run this I get:
Current Slot: null

According to gLiveView my BP is fully synced, up to date and TX count is moving up. Any thoughts?

Hi!

First, just execute cardano-cli query tip --mainnet to see what you are getting… maybe environment variable issue

hmmmm running that just now I get

"epoch": 255,
"hash": "ab95a8badf98f851c7289e65909fd785e19f26c4b83d7cdd29fb6bac9c093826",
"slot": 25199296,
"block": 5510617

To put it more in context, I am trying to run this:
currentSlot=$(cardano-cli query tip --mainnet | jq -r ‘.slotNo’)
echo Current Slot: $currentSlot

to retire a stake pool.

it looks like the key for slot number in your case is “slot” instead of “slotNo”. Try to run:

currentSlot=$(cardano-cli query tip --mainnet | jq -r ‘.slot’)
I don’t know why the key is different in your case.

That worked!

Next obstacle :confused:
fee=(cardano-cli transaction calculate-min-fee \ --tx-body-file tx.tmp \ --tx-in-count {txcnt}
–tx-out-count 1
–mainnet
–witness-count 2
–byron-witness-count 0
–protocol-params-file params.json | awk ‘{ print $1 }’)
echo fee: $fee

returns error:
Command failed: transaction calculate-min-fee Error: Error while decoding the protocol parameters at: “params.json” Error: “Error in $: key “decentralization” not found”

Any thoughts on that? Maybe not enough ADA to cover the transaction? I only have 2 ADA in the wallet currently

This is what’s in my params.json
{
“poolDeposit”: 500000000,
“protocolVersion”: {
“minor”: 0,
“major”: 3
},
“minUTxOValue”: 1000000,
“decentralisationParam”: 0.3,
“maxTxSize”: 16384,
“minPoolCost”: 340000000,
“minFeeA”: 44,
“maxBlockBodySize”: 65536,
“minFeeB”: 155381,
“eMax”: 18,
“extraEntropy”: {
“tag”: “NeutralNonce”
},
“maxBlockHeaderSize”: 1100,
“keyDeposit”: 2000000,
“nOpt”: 500,
“rho”: 3.0e-3,
“tau”: 0.2,
“a0”: 0.3
}

fee=$(cardano-cli transaction calculate-min-fee \
    --tx-body-file tx.tmp \
    --tx-in-count ${txcnt} \
    --tx-out-count 1 \
    --mainnet \
    --witness-count 2 \
    --byron-witness-count 0 \
    --protocol-params-file params.json | awk '{ print $1 }')
echo fee: $fee

I think you are missing “\” at the end of lines.

Last line doesn’t get a “back slash”
and echo is a new command.

Thanks for the reply though.

Solved the issue. I regenerated the params.json. For some reason the one I had wasn’t working.

cardano-cli query protocol-parameters
–mainnet
–mary-era
–out-file params.json