Algorand staking countdown

I have got a little script that calculates the current remaining time…

#!/bin/bash

# Constants
BLOCK_TARGET=46512890  # Block when staking starts
BLOCK_SPEED=2.788      # Blocks per second

# Get the current block from the blockchain using the goal command
CURRENT_BLOCK=$(goal node status | grep -oP '(?<=Last committed block: )\d+')

if [[ -z "$CURRENT_BLOCK" ]]; then
  echo "Error: Unable to retrieve current block. Ensure 'goal' is configured correctly."
  exit 1
fi

# Calculate remaining blocks
BLOCKS_REMAINING=$((BLOCK_TARGET - CURRENT_BLOCK))

if (( BLOCKS_REMAINING <= 0 )); then
  echo "Staking has already started or the target block has been reached."
  exit 0
fi

# Calculate remaining time in seconds (rounded to the nearest integer)
SECONDS_REMAINING=$(printf '%.0f' $(echo "$BLOCKS_REMAINING * $BLOCK_SPEED" | bc))
# Calculate the start date and time for multiple timezones
TIMEZONES=(
  "PST:UTC+8"
  "EST:UTC+5"
  "UTC:UTC"
  "CET:UTC-1"
  "CST:UTC-8"
  "JST:UTC-9"
  "AEST:UTC-10"
)
HOURS=$((SECONDS_REMAINING / 3600))
MINUTES=$(((SECONDS_REMAINING % 3600) / 60))
SECONDS=$((SECONDS_REMAINING % 60))

# Output the result
echo "Current block: $CURRENT_BLOCK"
echo "Target block: $BLOCK_TARGET"
echo "Blocks remaining: $BLOCKS_REMAINING"
echo "Time remaining: $HOURS hours, $MINUTES minutes, $SECONDS seconds"
echo "Estimated staking start dates and times:" > times_output.txt

for TZ_INFO in "${TIMEZONES[@]}"; do
  IFS=":" read -r LABEL TZ_VALUE <<< "$TZ_INFO"
  START_DATE=$(TZ=$TZ_VALUE date -d "@$(($(date -u +%s) + SECONDS_REMAINING + OFFSET_SECONDS + OFFSET_SECONDS))" '+%Y-%m-%d %H:%M:%S')
  echo "$START_DATE $LABEL" >> times_output.txt
  echo "$START_DATE $LABEL"
done

Currently it shows:

Current block: 46484928
Target block: 46512890
Blocks remaining: 27962
Time remaining: 21 hours, 39 minutes, 18 seconds
2025-01-23 06:07:40 PST
2025-01-23 09:07:40 EST
2025-01-23 14:07:40 UTC
2025-01-23 15:07:40 CET
2025-01-23 22:07:40 CST
2025-01-23 23:07:40 JST
2025-01-24 00:07:40 AEST
1 Like

@scholtz That’s great! Not many sites are ready for staking, and I don’t consider Liquid Staking here, because they make YOU to run a node. E.g. Valar says “Coming Soon”, Réti nodely.io laconically prints “Transaction failed…”, etc. Is it possible to stake at your sites, Ludo? How?

Incentives countdown on the web: https://algo.surf/

1 Like

Hey @Maugli Reti and Valar will only be able to deploy on MainNet once the upgrade is live, so expected a lot more info from them in the next few hours.

Yes, I see,
Well, now I see know important PR is: a countdown would be better then an error message!