Last active
June 10, 2024 15:39
-
-
Save Benhawkins18/f53244f83d8178e902b9f24584e2da67 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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