Skip to content

Instantly share code, notes, and snippets.

@Benhawkins18
Last active June 10, 2024 15:39
Show Gist options
  • Select an option

  • Save Benhawkins18/f53244f83d8178e902b9f24584e2da67 to your computer and use it in GitHub Desktop.

Select an option

Save Benhawkins18/f53244f83d8178e902b9f24584e2da67 to your computer and use it in GitHub Desktop.
import subprocess
import json
LAMPORTS_PER_SOL = 1_000_000_000
print("Running the Solana stakes command...")
result = subprocess.run(['solana', 'stakes', '--withdraw-authority', '4ZJhPQAgUseCsWhKvJLTmmRRUV74fdoTpQLNfKoekbPY', '--output', 'json'], capture_output=True, text=True)
print("Finished Running the Solana stakes command...")
# Load the captured JSON output
if result.returncode == 0:
stakes = json.loads(result.stdout)
else:
print("An error occurred running the Solana command.")
exit(1)
validators = set()
for stake in stakes:
validators.add(stake['delegatedVoteAccountAddress'])
total_stake = sum([stake['activeStake'] / LAMPORTS_PER_SOL for stake in stakes if "activeStake" in stake])
average_stake = total_stake / len(validators)
print(f"Found {len(validators)} validators with stake from the SFDP.")
print(f"Total stake from the SFDP: {total_stake:.0f}")
print(f"Average stake per validator: {average_stake:.0f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment