Skip to content

Instantly share code, notes, and snippets.

View Benhawkins18's full-sized avatar

Ben Hawkins Benhawkins18

View GitHub Profile
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:
@Benhawkins18
Benhawkins18 / solana_validator_metrics.py
Created May 10, 2024 17:57
Solana Validator Decentralization
import requests
from collections import defaultdict
# weights should sum to 100
def HHI(weights):
return sum([x**2 for x in weights])
MAX_HHI_SCORE = 10000
#NE is the number of nodes with a perfectly even distribution with an equivalent HHI score.
def NE(HHI_score):
return 1 / (HHI_score / MAX_HHI_SCORE)
## Must have solana CLI installed for this to work
import json
import subprocess
command_output = subprocess.check_output(["solana", "stakes", "--output", "json"])
stakes = json.loads(command_output)
total_sfdp_stake = 0
for stake in stakes:
@Benhawkins18
Benhawkins18 / confetti-succesfull-screen-tailwind.markdown
Created December 22, 2022 19:56
Confetti succesfull screen Tailwind