Created
April 9, 2022 15:32
-
-
Save enorms/53c1dbc807c69da0aaefcd68f4b3cf17 to your computer and use it in GitHub Desktop.
Unique wallets count
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
# Count unique wallets with votes recorded in all proposals | |
# for orangedaoxyz.eth | |
# | |
# https://docs.snapshot.org/graphql-api | |
# | |
import requests | |
import pandas as pd | |
URL = "https://hub.snapshot.org/graphql?operationName=Votes&query=query%20Votes%20%7B%0A%20%20votes%20(%0A%20%20%20%20first%3A%201000000000%0A%20%20%20%20skip%3A%200%0A%20%20%20%20where%3A%20%7B%0A%20%20%20%20%20%20space%3A%20%22orangedaoxyz.eth%22%0A%20%20%20%20%7D%0A%20%20%20%20orderBy%3A%20%22created%22%2C%0A%20%20%20%20orderDirection%3A%20desc%0A%20%20)%20%7B%0A%20%20%20%20id%0A%20%20%20%20voter%0A%20%20%20%20created%0A%20%20%20%20proposal%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%7D%0A%20%20%20%20choice%0A%20%20%20%20space%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A" | |
res = requests.get(URL) | |
res = res.json() | |
df = pd.DataFrame.from_dict(res) | |
df = df['data'] | |
df = df['votes'] | |
unique_voters = set() | |
for item in df: | |
unique_voters.add(item.get('voter')) | |
num_unique_voters = len(unique_voters) | |
print ({ | |
'num_unique_voters': num_unique_voters | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment