Skip to content

Instantly share code, notes, and snippets.

@Commoneffort
Created October 28, 2024 22:53
Show Gist options
  • Save Commoneffort/ed729fed8dd3ef3499d976efc66ac2c0 to your computer and use it in GitHub Desktop.
Save Commoneffort/ed729fed8dd3ef3499d976efc66ac2c0 to your computer and use it in GitHub Desktop.
Read Solana validator related accounts and balances
#!/bin/bash
# Define universal paths
CONFIG_DIR="/home/owl/.config/solana"
SOLANA_DIR="/home/owl/solana"
# List of account JSON files using the universal paths
accounts=(
"$CONFIG_DIR/id.json"
"$SOLANA_DIR/identity.json"
"$SOLANA_DIR/stake.json"
"$SOLANA_DIR/withdraw.json"
"$SOLANA_DIR/vote.json"
)
# Iterate over each account file
for account in "${accounts[@]}"; do
if [[ -f "$account" ]]; then
# Get the public key from the file
public_key=$(solana-keygen pubkey "$account")
# Get the balance using the public key
balance=$(solana balance "$public_key" 2>/dev/null)
# Display the account file, public key, and balance
echo "Account File: $account"
echo "Public Key: $public_key"
echo "Balance: $balance SOL"
echo
else
echo "Account File: $account not found!"
echo
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment