Skip to content

Commit aa4781f

Browse files
author
Kotsias, Panagiotis-Christos
committed
Added all free modules
1 parent f67045e commit aa4781f

File tree

16 files changed

+712
-224
lines changed

16 files changed

+712
-224
lines changed

etherscan/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
from .modules.accounts import Accounts as accounts
2+
from .modules.blocks import Blocks as blocks
23
from .modules.contracts import Contracts as contracts
4+
from .modules.gastracker import GasTracker as gastracker
5+
from .modules.proxy import Proxy as proxy
6+
from .modules.stats import Stats as stats
37
from .modules.tokens import Tokens as tokens
48
from .modules.transactions import Transactions as transactions

etherscan/configs/stable.json

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,133 @@
11
{
2+
"get_proxy_block_number": {
3+
"module": "proxy",
4+
"kwargs": {}
5+
},
6+
"get_proxy_block_by_number": {
7+
"module": "proxy",
8+
"kwargs": {
9+
"tag": "0x10d4f"
10+
}
11+
},
12+
"get_proxy_uncle_by_block_number_and_index": {
13+
"module": "proxy",
14+
"kwargs": {
15+
"tag": "0x210A9B",
16+
"index": "0x0"
17+
}
18+
},
19+
"get_proxy_block_transaction_count_by_number": {
20+
"module": "proxy",
21+
"kwargs": {
22+
"tag": "0x10FB78"
23+
}
24+
},
25+
"get_proxy_transaction_by_hash": {
26+
"module": "proxy",
27+
"kwargs": {
28+
"txhash": "0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1"
29+
}
30+
},
31+
"get_proxy_transaction_by_block_number_and_index": {
32+
"module": "proxy",
33+
"kwargs": {
34+
"tag": "0x10d4f",
35+
"index": "0x0"
36+
}
37+
},
38+
"get_proxy_transaction_count": {
39+
"module": "proxy",
40+
"kwargs": {
41+
"address": "0x2910543af39aba0cd09dbb2d50200b3e800a63d2"
42+
}
43+
},
44+
"get_proxy_transaction_receipt": {
45+
"module": "proxy",
46+
"kwargs": {
47+
"txhash": "0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1"
48+
}
49+
},
50+
"get_proxy_call": {
51+
"module": "proxy",
52+
"kwargs": {
53+
"to": "0xAEEF46DB4855E25702F8237E8f403FddcaF931C0",
54+
"data": "0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724"
55+
}
56+
},
57+
"get_proxy_code_at": {
58+
"module": "proxy",
59+
"kwargs": {
60+
"address": "0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c"
61+
}
62+
},
63+
"get_proxy_storage_position_at": {
64+
"module": "proxy",
65+
"kwargs": {
66+
"position": "0x0",
67+
"address": "0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd"
68+
}
69+
},
70+
"get_proxy_gas_price": {
71+
"module": "proxy",
72+
"kwargs": {}
73+
},
74+
"get_proxy_est_gas": {
75+
"module": "proxy",
76+
"kwargs": {
77+
"data": "0x4e71d92d",
78+
"to": "0xf0160428a8552ac9bb7e050d90eeade4ddd52843",
79+
"value": "0xff22",
80+
"gas_price": "0x51da038cc",
81+
"gas": "0x5f5e0ff"
82+
}
83+
},
84+
"get_est_confirmation_time": {
85+
"module": "gastracker",
86+
"kwargs": {
87+
"gas_price": "2000000000"
88+
}
89+
},
90+
"get_gas_oracle": {
91+
"module": "gastracker",
92+
"kwargs": {}
93+
},
94+
"get_block_reward_by_block_number": {
95+
"module": "blocks",
96+
"kwargs": {
97+
"block_no": "2165403"
98+
}
99+
},
100+
"get_est_block_countdown_time_by_block_number": {
101+
"module": "blocks",
102+
"kwargs": {
103+
"block_no": "99999999"
104+
}
105+
},
106+
"get_block_number_by_timestamp": {
107+
"module": "blocks",
108+
"kwargs": {
109+
"timestamp": "1578638524",
110+
"closest": "before"
111+
}
112+
},
113+
"get_total_eth_supply": {
114+
"module": "stats",
115+
"kwargs": {}
116+
},
117+
"get_eth_last_price": {
118+
"module": "stats",
119+
"kwargs": {}
120+
},
121+
"get_eth_nodes_size": {
122+
"module": "stats",
123+
"kwargs": {
124+
"start_date": "2019-02-01",
125+
"end_date": "2019-02-28",
126+
"client_type": "geth",
127+
"sync_mode": "default",
128+
"sort": "asc"
129+
}
130+
},
2131
"get_total_supply_by_contract_address": {
3132
"module": "tokens",
4133
"kwargs": {
@@ -117,6 +246,25 @@
117246
"sort": "asc"
118247
}
119248
},
249+
"get_erc20_token_transfer_events_by_contract_address_paginated": {
250+
"module": "accounts",
251+
"kwargs": {
252+
"contract_address": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
253+
"page": 1,
254+
"offset": 100,
255+
"sort": "asc"
256+
}
257+
},
258+
"get_erc20_token_transfer_events_by_address_and_contract_paginated": {
259+
"module": "accounts",
260+
"kwargs": {
261+
"contract_address": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
262+
"address": "0x4e83362442b8d1bec281594cea3050c8eb01311c",
263+
"page": 1,
264+
"offset": 100,
265+
"sort": "asc"
266+
}
267+
},
120268
"get_erc721_token_transfer_events_by_address": {
121269
"module": "accounts",
122270
"kwargs": {
@@ -126,10 +274,37 @@
126274
"sort": "asc"
127275
}
128276
},
277+
"get_erc721_token_transfer_events_by_contract_address_paginated": {
278+
"module": "accounts",
279+
"kwargs": {
280+
"contract_address": "0x06012c8cf97bead5deae237070f9587f8e7a266d",
281+
"page": 1,
282+
"offset": 100,
283+
"sort": "asc"
284+
}
285+
},
286+
"get_erc721_token_transfer_events_by_address_and_contract_paginated": {
287+
"module": "accounts",
288+
"kwargs": {
289+
"contract_address": "0x06012c8cf97bead5deae237070f9587f8e7a266d",
290+
"address": "0x6975be450864c02b4613023c2152ee0743572325",
291+
"page": 1,
292+
"offset": 100,
293+
"sort": "asc"
294+
}
295+
},
129296
"get_mined_blocks_by_address": {
130297
"module": "accounts",
131298
"kwargs": {
132299
"address": "0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b"
133300
}
301+
},
302+
"get_mined_blocks_by_address_paginated": {
303+
"module": "accounts",
304+
"kwargs": {
305+
"address": "0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b",
306+
"page": 1,
307+
"offset": 100
308+
}
134309
}
135310
}

etherscan/enums/actions_enum.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,28 @@ class ActionsEnum:
66
BALANCE_HISTORY: str = "balancehistory"
77
BALANCE_MULTI: str = "balancemulti"
88
BALANCE: str = "balance"
9+
CHAIN_SIZE: str = "chainsize"
10+
ETH_BLOCK_NUMBER: str = "eth_blockNumber"
11+
ETH_CALL: str = "eth_call"
12+
ETH_ESTIMATE_GAS: str = "eth_estimateGas"
13+
ETH_GAS_PRICE: str = "eth_gasPrice"
14+
ETH_GET_BLOCK_BY_NUMBER: str = "eth_getBlockByNumber"
15+
ETH_GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER: str = "eth_getBlockTransactionCountByNumber"
16+
ETH_GET_TRANSACTION_BY_BLOCK_NUMBER_AND_INDEX: str = "eth_getTransactionByBlockNumberAndIndex"
17+
ETH_GET_CODE: str = "eth_getCode"
18+
ETH_GET_STORAGE_AT: str = "eth_getStorageAt"
19+
ETH_GET_TRANSACTION_BY_HASH: str = "eth_getTransactionByHash"
20+
ETH_GET_TRANSACTION_COUNT: str = "eth_getTransactionCount"
21+
ETH_GET_TRANSACTION_RECEIPT: str = "eth_getTransactionReceipt"
22+
ETH_GET_UNCLE_BY_BLOCK_NUMBER_AND_INDEX: str = "eth_getUncleByBlockNumberAndIndex"
23+
ETH_PRICE: str = "ethprice"
24+
ETH_SUPPLY: str = "ethsupply"
25+
GAS_ESTIMATE: str = "gasestimate"
26+
GAS_ORACLE: str = "gasoracle"
927
GET_ABI: str = "getabi"
28+
GET_BLOCK_COUNTDOWN: str = "getblockcountdown"
29+
GET_BLOCK_NUMBER_BY_TIME: str = "getblocknobytime"
30+
GET_BLOCK_REWARD: str = "getblockreward"
1031
GET_MINED_BLOCKS: str = "getminedblocks"
1132
GET_SOURCE_CODE: str = "getsourcecode"
1233
GET_STATUS: str = "getstatus"

etherscan/enums/fields_enum.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ class FieldsEnum:
99
BLOCK_TYPE: str = "&blocktype="
1010
BLOCKNO: str = "&blockno="
1111
BOOLEAN: str = "&boolean="
12+
CLIENT_TYPE: str = "&clienttype="
13+
CLOSEST: str = "&closest="
1214
CONTRACT_ADDRESS: str = "&contractaddress="
1315
DATA: str = "&data="
1416
END_BLOCK: str = "&endblock="
17+
END_DATE: str = "&enddate="
1518
GAS_PRICE: str = "&gasPrice="
1619
GAS: str = "&gas="
1720
HEX: str = "&hex="
@@ -23,7 +26,10 @@ class FieldsEnum:
2326
PREFIX: str = "https://api.etherscan.io/api?"
2427
SORT: str = "&sort="
2528
START_BLOCK: str = "&startblock="
29+
START_DATE: str = "&startdate="
30+
SYNC_MODE: str = "&syncmode="
2631
TAG: str = "&tag="
32+
TIMESTAMP: str = "&timestamp="
2733
TO: str = "&to="
2834
TXHASH: str = "&txhash="
2935
VALUE: str = "&value="

etherscan/enums/modules_enum.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@dataclass(frozen=True)
55
class ModulesEnum:
66
ACCOUNT: str = "account"
7+
BLOCK: str = "block"
78
CONTRACT: str = "contract"
89
GASTRACKER: str = "gastracker"
910
PROXY: str = "proxy"

etherscan/etherscan.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import json
2+
3+
import requests
4+
5+
import etherscan
6+
from etherscan.enums.fields_enum import FieldsEnum as fields
7+
from etherscan.utils.parsing import ResponseParser as parser
8+
9+
10+
class Etherscan:
11+
@staticmethod
12+
def __load_config(config_path: str) -> dict:
13+
with open(config_path, "r") as f:
14+
return json.load(f)
15+
16+
@staticmethod
17+
def __run(func, api_key):
18+
def wrapper(*args, **kwargs):
19+
url = (
20+
f"{fields.PREFIX}"
21+
f"{func(*args, **kwargs)}"
22+
f"{fields.API_KEY}"
23+
f"{api_key}"
24+
)
25+
r = requests.get(url)
26+
return parser.parse(r)
27+
28+
return wrapper
29+
30+
@classmethod
31+
def from_config(cls, config_path: str, api_key: str):
32+
config = cls.__load_config(config_path)
33+
for func, v in config.items():
34+
if not func.startswith("_"): # disabled if _
35+
attr = getattr(getattr(etherscan, v["module"]), func)
36+
setattr(cls, func, cls.__run(attr, api_key))
37+
return cls

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy