Last active
August 26, 2023 09:37
-
-
Save d13co/1fe40467cfb8683a2e9fefab7771b719 to your computer and use it in GitHub Desktop.
algokey-gen.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: @D13_co | |
# Context: https://d13.co/posts/redundant-participation-nodes-on-algorand/ | |
set -e | |
# first argument: address | |
address=$1 | |
# second argument: duration in rounds, defaults to 650K | |
duration=$2 | |
duration=${duration:-650000} | |
if [ "$address" == "" ]; then | |
echo "Usage: $0 <address> [<duration>]" | |
echo "address is mandatory. duration is optional" | |
exit 1 | |
fi | |
# try to run goal node status and fail if it errors | |
if ! (algorun goal node status > /dev/null 2>&1 || goal node status > /dev/null 2>&1) then | |
echo "Failed to run: [algorun] goal node status" | |
echo "Please check that you are able to run this command and try again." | |
exit 2 | |
fi | |
start=$((algorun goal node status 2> /dev/null || goal node status) | grep "Last committed block" | awk '{print $4}') | |
echo Current round: $start | |
# Start round is +10 from current round | |
start=$((start + 10)) | |
echo "Start round: $start (+10)" | |
# End round calculation | |
end=$((start + duration)) | |
echo "End round: $end (+$duration)" | |
# Dilution is square root of duration | |
# Using awk for portability | |
sqrt=`awk "BEGIN {printf \"%.0f\", sqrt($duration)}"` | |
echo "Dilution (sqrt(end-start)): $sqrt" | |
echo Execute this command to generate your key: | |
echo "" | |
echo "algokey part generate --parent $address --first $start --last $end --dilution $sqrt --keyfile $address-$start-$end.partkey" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment