-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLecture5d.py
59 lines (46 loc) · 1.02 KB
/
Lecture5d.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import pandas as pd
import plotly.express as px
from gql import gql, Client
from gql.transport.requests import RequestsHTTPTransport
#---------- Extract data from Uniswap Subgraph ----------
sample_transport=RequestsHTTPTransport(
url='https://api.thegraph.com/subgraphs/name/aragon/aragon-tokens-xdai',
verify=True,
retries=3,
)
client = Client(
transport=sample_transport
)
query = gql('''
query {
miniMeTokens(where:{name: "morphosis"}) {
name
totalSupply
holders {
address
balance
}
}
}
''')
response = client.execute(query)
print(response)
print(response['miniMeTokens'][0]['holders'])
holders = []
for i in response['miniMeTokens'][0]['holders']:
holders.append([
i['address'],
i['balance'],
])
print(holders)
print()
print()
df = pd.DataFrame(holders)
print(df)
df[1] = df[1].astype(float)/1000000000000000000
df.columns=['Holder', 'Amount']
print()
print()
print(df)
fig = px.bar(df, x='Holder', y='Amount')
fig.show()