Skip to content

Commit 08e3165

Browse files
committed
create README.md
0 parents  commit 08e3165

File tree

5 files changed

+341
-0
lines changed

5 files changed

+341
-0
lines changed

‎README.md

Whitespace-only changes.

‎accounts.py

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
@author: Joey Chen
5+
"""
6+
7+
import requests
8+
9+
class accounts():
10+
11+
def __init__(self,api_key):
12+
self.api_key = api_key
13+
14+
def get_eth_balance(self,address,tag):
15+
16+
17+
url = ( "https://api.etherscan.io/api"+
18+
"?module=account"+
19+
"&action=balance"+
20+
"&address="+address+
21+
"&tag="+tag+
22+
"&apikey="+self.api_key
23+
24+
)
25+
26+
r = requests.get(url)
27+
28+
return r.json()['result']
29+
30+
31+
def get_eth_balance_multi(self,address,tag):
32+
33+
url = ( "https://api.etherscan.io/api"+
34+
"?module=account"+
35+
"&action=balancemulti"+
36+
"&address="+address+
37+
"&tag="+tag+
38+
"&apikey="+self.api_key
39+
40+
)
41+
42+
r = requests.get(url)
43+
44+
return r.json()['result']
45+
46+
def get_normal_txn_by_address(self,address,startblk,endblk,page,offset,sort):
47+
48+
url = (
49+
"https://api.etherscan.io/api"+
50+
"?module=account"+
51+
"&action=txlist"+
52+
"&address="+address+
53+
"&startblock="+str(startblk)+
54+
"&endblock="+str(endblk)+
55+
"&page="+str(page)+
56+
"&offset="+str(offset)+
57+
"&sort="+sort+
58+
"&apikey="+self.api_key
59+
)
60+
r = requests.get(url)
61+
62+
return r.json()['result']
63+
64+
def get_internal_txn_by_address(self,address,startblk,endblk,page,offset,sort):
65+
66+
url = (
67+
"https://api.etherscan.io/api"+
68+
"?module=account"+
69+
"&action=txlistinternal"+
70+
"&address="+address+
71+
"&startblock="+str(startblk)+
72+
"&endblock="+str(endblk)+
73+
"&page="+str(page)+
74+
"&offset="+str(offset)+
75+
"&sort="+sort+
76+
"&apikey="+self.api_key
77+
)
78+
r = requests.get(url)
79+
80+
return r.json()['result']
81+
82+
def get_erc20_transfer_txn_by_address(self,address,contract_address,page,offset,startblk,endblk,sort):
83+
84+
url = (
85+
"https://api.etherscan.io/api"+
86+
"?module=account"+
87+
"&action=tokentx"+
88+
"&contractaddress="+contract_address+
89+
"&address="+address+
90+
"&page="+str(page)+
91+
"&offset="+str(offset)+
92+
"&startblock="+str(startblk)+
93+
"&endblock="+str(endblk)+
94+
"&sort="+sort+
95+
"&apikey="+self.api_key
96+
)
97+
98+
r = requests.get(url)
99+
return r.json()['result']
100+
101+
def get_erc721_transfer_txn_by_address(self,address,contract_address,page,offset,startblk,endblk,sort):
102+
103+
url = (
104+
"https://api.etherscan.io/api"+
105+
"?module=account"+
106+
"&action=tokennfttx"+
107+
"&contractaddress="+contract_address+
108+
"&address="+address+
109+
"&page="+str(page)+
110+
"&offset="+str(offset)+
111+
"&startblock="+str(startblk)+
112+
"&endblock="+str(endblk)+
113+
"&sort="+sort+
114+
"&apikey="+self.api_key
115+
)
116+
117+
r = requests.get(url)
118+
return r.json()['result']
119+
120+
def get_erc1155_transfer_txn_by_address(self,address,contract_address,page,offset,startblk,endblk,sort):
121+
122+
url = (
123+
"https://api.etherscan.io/api"+
124+
"?module=account"+
125+
"&action=token1155tx"+
126+
"&contractaddress="+contract_address+
127+
"&address="+address+
128+
"&page="+str(page)+
129+
"&offset="+str(offset)+
130+
"&startblock="+str(startblk)+
131+
"&endblock="+str(endblk)+
132+
"&sort="+sort+
133+
"&apikey="+self.api_key
134+
)
135+
136+
r = requests.get(url)
137+
return r.json()['result']
138+

‎contracts.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
@author: Joey Chen
5+
"""
6+
7+
import requests
8+
9+
class contracts():
10+
11+
def __init__(self,api_key):
12+
self.api_key = api_key
13+
14+
def get_contract_abi(self,contract_address):
15+
16+
17+
url = (
18+
"https://api.etherscan.io/api"+
19+
"?module=contract"+
20+
"&action=getabi"+
21+
"&address="+contract_address+
22+
"&apikey="+self.api_key
23+
24+
)
25+
26+
r = requests.get(url)
27+
28+
return r.json()['result']
29+
30+
31+
def get_contract_source_code(self,contract_address):
32+
33+
34+
url = (
35+
"https://api.etherscan.io/api"+
36+
"?module=contract"+
37+
"&action=getsourcecode"+
38+
"&address="+contract_address+
39+
"&apikey="+self.api_key
40+
41+
)
42+
43+
r = requests.get(url)
44+
45+
return r.json()['result']
46+
47+
def get_contract_creation(self,contract_address):
48+
49+
50+
url = (
51+
"https://api.etherscan.io/api"+
52+
"?module=contract"+
53+
"&action=getcontractcreation"+
54+
"&contractaddresses="+contract_address+
55+
"&apikey="+self.api_key
56+
57+
)
58+
59+
r = requests.get(url)
60+
61+
return r.json()
62+

‎proxy.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
@author: Joey Chen
5+
"""
6+
7+
import requests
8+
9+
class proxy():
10+
11+
def __init__(self,api_key):
12+
self.api_key = api_key
13+
14+
def eth_block_num(self):
15+
16+
url = (
17+
"https://api.etherscan.io/api"+
18+
"?module=proxy"+
19+
"&action=eth_blockNumber"+
20+
"&apikey="+self.api_key
21+
22+
)
23+
24+
r = requests.get(url)
25+
26+
return r.json()['result']
27+
28+
29+
def eth_txn_counts(self,address,tag):
30+
31+
32+
url = (
33+
"https://api.etherscan.io/api"+
34+
"?module=proxy"+
35+
"&action=eth_getTransactionCount"+
36+
"&address="+address+
37+
"&tag="+tag+
38+
"&apikey="+self.api_key
39+
40+
)
41+
42+
r = requests.get(url)
43+
44+
return r.json()['result']
45+
46+
def eth_send_Raw_Transaction(self,hex):
47+
48+
49+
url = (
50+
"https://api.etherscan.io/api"+
51+
"?module=proxy"+
52+
"&action=eth_sendRawTransaction"+
53+
"&hex="+hex+
54+
"&apikey="+self.api_key
55+
56+
)
57+
58+
r = requests.get(url)
59+
60+
return r.json()['result']
61+
62+
def eth_gas_price(self):
63+
64+
url = (
65+
"https://api.etherscan.io/api"+
66+
"?module=proxy"+
67+
"&action=eth_gasPrice"+
68+
"&apikey="+self.api_key
69+
70+
)
71+
72+
r = requests.get(url)
73+
74+
return r.json()['result']
75+
76+
def eth_estimatedG_gas(self,data,to,value,gasPrice,gas):
77+
78+
url = (
79+
"https://api.etherscan.io/api"+
80+
"?module=proxy"+
81+
"&action=eth_estimateGas"+
82+
"&data="+data+
83+
"&to="+to+
84+
"&value="+value+
85+
"&gasPrice="+gasPrice+
86+
"&gas="+gas+
87+
"&apikey="+self.api_key
88+
89+
)
90+
91+
r = requests.get(url)
92+
93+
return r.json()['result']
94+
95+
96+

‎transactions.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
@author: Joey Chen
5+
"""
6+
7+
import requests
8+
9+
class transactions():
10+
11+
def __init__(self,api_key):
12+
self.api_key = api_key
13+
14+
def get_txn_status(self,txn_hash):
15+
16+
17+
url = (
18+
"https://api.etherscan.io/api"+
19+
"?module=transaction"+
20+
"&action=getstatus"+
21+
"&txhash="+txn_hash+
22+
"&apikey="+self.api_key
23+
24+
)
25+
26+
r = requests.get(url)
27+
28+
return r.json()['result']
29+
30+
def get_txn_receipt_status(self,txn_hash):
31+
32+
33+
url = (
34+
"https://api.etherscan.io/api"+
35+
"?module=transaction"+
36+
"&action=gettxreceiptstatus"+
37+
"&txhash="+txn_hash+
38+
"&apikey="+self.api_key
39+
40+
)
41+
42+
r = requests.get(url)
43+
44+
return r.json()['result']
45+

0 commit comments

Comments
 (0)
X