Skip to content

Commit 16bb505

Browse files
committed
add get_contract_creator_and_creation_tx_hash
1 parent e059d7c commit 16bb505

File tree

142 files changed

+158905
-62860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+158905
-62860
lines changed

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
install:
2+
pip install -e .
3+
4+
.PHONY: test
5+
test:
6+
bash ./run_tests.sh $(API_KEY)
7+
8+
clean:
9+
find . -type d -name __pycache__ -exec rm -rf "{}" +
10+
rm -rf build *.egg-info
11+
rm -f .black .flake8 .errors .coverage
12+
13+
fmt:
14+
black -l 135 etherscan
15+
flake8 --max-line-len 135 etherscan

etherscan/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,16 @@
88
from .modules.stats import Stats as stats
99
from .modules.tokens import Tokens as tokens
1010
from .modules.transactions import Transactions as transactions
11+
12+
__all__ = [
13+
"Etherscan",
14+
"accounts",
15+
"blocks",
16+
"contracts",
17+
"gastracker",
18+
"pro",
19+
"proxy",
20+
"stats",
21+
"tokens",
22+
"transactions",
23+
]

etherscan/configs/GOERLI-stable.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@
153153
"address": "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"
154154
}
155155
},
156+
"get_contract_creator_and_creation_tx_hash": {
157+
"module": "contracts",
158+
"kwargs": {
159+
"addresses": ["0x7af963cF6D228E564e2A0aA0DdBF06210B38615D"]
160+
}
161+
},
156162
"get_contract_execution_status": {
157163
"module": "transactions",
158164
"kwargs": {
@@ -307,4 +313,4 @@
307313
"offset": 100
308314
}
309315
}
310-
}
316+
}

etherscan/configs/KOVAN-stable.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@
153153
"address": "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"
154154
}
155155
},
156+
"get_contract_creator_and_creation_tx_hash": {
157+
"module": "contracts",
158+
"kwargs": {
159+
"addresses": ["0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"]
160+
}
161+
},
156162
"get_contract_execution_status": {
157163
"module": "transactions",
158164
"kwargs": {
@@ -307,4 +313,4 @@
307313
"offset": 100
308314
}
309315
}
310-
}
316+
}

etherscan/configs/MAIN-stable.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@
153153
"address": "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"
154154
}
155155
},
156+
"get_contract_creator_and_creation_tx_hash": {
157+
"module": "contracts",
158+
"kwargs": {
159+
"addresses": ["0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"]
160+
}
161+
},
156162
"get_contract_execution_status": {
157163
"module": "transactions",
158164
"kwargs": {
@@ -463,4 +469,4 @@
463469
"sort": "asc"
464470
}
465471
}
466-
}
472+
}

etherscan/configs/RINKEBY-stable.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@
153153
"address": "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"
154154
}
155155
},
156+
"get_contract_creator_and_creation_tx_hash": {
157+
"module": "contracts",
158+
"kwargs": {
159+
"addresses": ["0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"]
160+
}
161+
},
156162
"get_contract_execution_status": {
157163
"module": "transactions",
158164
"kwargs": {
@@ -307,4 +313,4 @@
307313
"offset": 100
308314
}
309315
}
310-
}
316+
}

etherscan/configs/ROPSTEN-stable.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@
153153
"address": "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"
154154
}
155155
},
156+
"get_contract_creator_and_creation_tx_hash": {
157+
"module": "contracts",
158+
"kwargs": {
159+
"addresses": ["0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"]
160+
}
161+
},
156162
"get_contract_execution_status": {
157163
"module": "transactions",
158164
"kwargs": {
@@ -307,4 +313,4 @@
307313
"offset": 100
308314
}
309315
}
310-
}
316+
}

etherscan/enums/actions_enum.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,10 @@ class ActionsEnum:
2828
ETH_ESTIMATE_GAS: str = "eth_estimateGas"
2929
ETH_GAS_PRICE: str = "eth_gasPrice"
3030
ETH_GET_BLOCK_BY_NUMBER: str = "eth_getBlockByNumber"
31-
ETH_GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER: str = (
32-
"eth_getBlockTransactionCountByNumber"
33-
)
31+
ETH_GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER: str = "eth_getBlockTransactionCountByNumber"
3432
ETH_GET_CODE: str = "eth_getCode"
3533
ETH_GET_STORAGE_AT: str = "eth_getStorageAt"
36-
ETH_GET_TRANSACTION_BY_BLOCK_NUMBER_AND_INDEX: str = (
37-
"eth_getTransactionByBlockNumberAndIndex"
38-
)
34+
ETH_GET_TRANSACTION_BY_BLOCK_NUMBER_AND_INDEX: str = "eth_getTransactionByBlockNumberAndIndex"
3935
ETH_GET_TRANSACTION_BY_HASH: str = "eth_getTransactionByHash"
4036
ETH_GET_TRANSACTION_COUNT: str = "eth_getTransactionCount"
4137
ETH_GET_TRANSACTION_RECEIPT: str = "eth_getTransactionReceipt"
@@ -48,6 +44,7 @@ class ActionsEnum:
4844
GET_BLOCK_COUNTDOWN: str = "getblockcountdown"
4945
GET_BLOCK_NUMBER_BY_TIME: str = "getblocknobytime"
5046
GET_BLOCK_REWARD: str = "getblockreward"
47+
GET_CONTRACT_CREATION: str = "getcontractcreation"
5148
GET_MINED_BLOCKS: str = "getminedblocks"
5249
GET_SOURCE_CODE: str = "getsourcecode"
5350
GET_STATUS: str = "getstatus"

etherscan/enums/fields_enum.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class FieldsEnum:
1212
CLIENT_TYPE: str = "&clienttype="
1313
CLOSEST: str = "&closest="
1414
CONTRACT_ADDRESS: str = "&contractaddress="
15+
CONTRACT_ADDRESSES: str = "&contractaddresses="
1516
DATA: str = "&data="
1617
END_BLOCK: str = "&endblock="
1718
END_DATE: str = "&enddate="

etherscan/enums/modules_enum.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ class ModulesEnum:
1111
STATS: str = "stats"
1212
TOKEN: str = "token"
1313
TRANSACTION: str = "transaction"
14-

etherscan/etherscan.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ def __load_config(config_path: str) -> dict:
2424
def __run(func, api_key: str, net: str):
2525
def wrapper(*args, **kwargs):
2626
url = (
27-
f"{fields.PREFIX.format(net.lower()).replace('-main','')}"
28-
f"{func(*args, **kwargs)}"
29-
f"{fields.API_KEY}"
30-
f"{api_key}"
27+
f"{fields.PREFIX.format(net.lower()).replace('-main','')}" f"{func(*args, **kwargs)}" f"{fields.API_KEY}" f"{api_key}"
3128
)
3229
r = requests.get(url, headers={"User-Agent": ""})
3330
return parser.parse(r)

etherscan/modules/accounts.py

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ def get_eth_balance_multiple(addresses: List[str]) -> str:
4444

4545
@staticmethod
4646
def get_normal_txs_by_address(
47-
address: str, startblock: int, endblock: int, sort: str,
47+
address: str,
48+
startblock: int,
49+
endblock: int,
50+
sort: str,
4851
) -> str:
4952
# NOTE: Returns the last 10k events
5053
url = (
@@ -65,7 +68,12 @@ def get_normal_txs_by_address(
6568

6669
@staticmethod
6770
def get_normal_txs_by_address_paginated(
68-
address: str, page: int, offset: int, startblock: int, endblock: int, sort: str,
71+
address: str,
72+
page: int,
73+
offset: int,
74+
startblock: int,
75+
endblock: int,
76+
sort: str,
6977
) -> str:
7078
url = (
7179
f"{fields.MODULE}"
@@ -89,7 +97,10 @@ def get_normal_txs_by_address_paginated(
8997

9098
@staticmethod
9199
def get_internal_txs_by_address(
92-
address: str, startblock: int, endblock: int, sort: str,
100+
address: str,
101+
startblock: int,
102+
endblock: int,
103+
sort: str,
93104
) -> str:
94105
# NOTE: Returns the last 10k events
95106
url = (
@@ -110,7 +121,12 @@ def get_internal_txs_by_address(
110121

111122
@staticmethod
112123
def get_internal_txs_by_address_paginated(
113-
address: str, page: int, offset: int, startblock: int, endblock: int, sort: str,
124+
address: str,
125+
page: int,
126+
offset: int,
127+
startblock: int,
128+
endblock: int,
129+
sort: str,
114130
) -> str:
115131
url = (
116132
f"{fields.MODULE}"
@@ -135,19 +151,16 @@ def get_internal_txs_by_address_paginated(
135151
@staticmethod
136152
def get_internal_txs_by_txhash(txhash: str) -> str:
137153
# NOTE: Returns the last 10k events
138-
url = (
139-
f"{fields.MODULE}"
140-
f"{modules.ACCOUNT}"
141-
f"{fields.ACTION}"
142-
f"{actions.TXLIST_INTERNAL}"
143-
f"{fields.TXHASH}"
144-
f"{txhash}"
145-
)
154+
url = f"{fields.MODULE}" f"{modules.ACCOUNT}" f"{fields.ACTION}" f"{actions.TXLIST_INTERNAL}" f"{fields.TXHASH}" f"{txhash}"
146155
return url
147156

148157
@staticmethod
149158
def get_internal_txs_by_block_range_paginated(
150-
startblock: int, endblock: int, page: int, offset: int, sort: str,
159+
startblock: int,
160+
endblock: int,
161+
page: int,
162+
offset: int,
163+
sort: str,
151164
) -> str:
152165
# NOTE: Returns the last 10k events
153166
url = (
@@ -170,7 +183,10 @@ def get_internal_txs_by_block_range_paginated(
170183

171184
@staticmethod
172185
def get_erc20_token_transfer_events_by_address(
173-
address: str, startblock: int, endblock: int, sort: str,
186+
address: str,
187+
startblock: int,
188+
endblock: int,
189+
sort: str,
174190
) -> str:
175191
# NOTE: Returns the last 10k events
176192
url = (
@@ -190,10 +206,7 @@ def get_erc20_token_transfer_events_by_address(
190206
return url
191207

192208
@staticmethod
193-
def get_erc20_token_transfer_events_by_contract_address_paginated(
194-
contract_address: str, page: int, offset: int, sort: str
195-
) -> str:
196-
209+
def get_erc20_token_transfer_events_by_contract_address_paginated(contract_address: str, page: int, offset: int, sort: str) -> str:
197210
url = (
198211
f"{fields.MODULE}"
199212
f"{modules.ACCOUNT}"
@@ -214,7 +227,6 @@ def get_erc20_token_transfer_events_by_contract_address_paginated(
214227
def get_erc20_token_transfer_events_by_address_and_contract_paginated(
215228
contract_address: str, address: str, page: int, offset: int, sort: str
216229
) -> str:
217-
218230
url = (
219231
f"{fields.MODULE}"
220232
f"{modules.ACCOUNT}"
@@ -235,7 +247,10 @@ def get_erc20_token_transfer_events_by_address_and_contract_paginated(
235247

236248
@staticmethod
237249
def get_erc721_token_transfer_events_by_address(
238-
address: str, startblock: int, endblock: int, sort: str,
250+
address: str,
251+
startblock: int,
252+
endblock: int,
253+
sort: str,
239254
) -> str:
240255
url = (
241256
f"{fields.MODULE}"
@@ -310,9 +325,7 @@ def get_mined_blocks_by_address(address: str) -> str:
310325
return url
311326

312327
@staticmethod
313-
def get_mined_blocks_by_address_paginated(
314-
address: str, page: int, offset: int
315-
) -> str:
328+
def get_mined_blocks_by_address_paginated(address: str, page: int, offset: int) -> str:
316329
url = (
317330
f"{fields.MODULE}"
318331
f"{modules.ACCOUNT}"

etherscan/modules/blocks.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,13 @@
66
class Blocks:
77
@staticmethod
88
def get_block_reward_by_block_number(block_no: str) -> str:
9-
url = (
10-
f"{fields.MODULE}"
11-
f"{modules.BLOCK}"
12-
f"{fields.ACTION}"
13-
f"{actions.GET_BLOCK_REWARD}"
14-
f"{fields.BLOCKNO}"
15-
f"{block_no}"
16-
)
9+
url = f"{fields.MODULE}" f"{modules.BLOCK}" f"{fields.ACTION}" f"{actions.GET_BLOCK_REWARD}" f"{fields.BLOCKNO}" f"{block_no}"
1710
return url
1811

1912
@staticmethod
2013
def get_est_block_countdown_time_by_block_number(block_no: str) -> str:
2114
url = (
22-
f"{fields.MODULE}"
23-
f"{modules.BLOCK}"
24-
f"{fields.ACTION}"
25-
f"{actions.GET_BLOCK_COUNTDOWN}"
26-
f"{fields.BLOCKNO}"
27-
f"{block_no}"
15+
f"{fields.MODULE}" f"{modules.BLOCK}" f"{fields.ACTION}" f"{actions.GET_BLOCK_COUNTDOWN}" f"{fields.BLOCKNO}" f"{block_no}"
2816
)
2917
return url
3018

etherscan/modules/contracts.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from functools import reduce
2+
from typing import List
3+
14
from etherscan.enums.actions_enum import ActionsEnum as actions
25
from etherscan.enums.fields_enum import FieldsEnum as fields
36
from etherscan.enums.modules_enum import ModulesEnum as modules
@@ -6,24 +9,23 @@
69
class Contracts:
710
@staticmethod
811
def get_contract_abi(address: str) -> str:
9-
url = (
10-
f"{fields.MODULE}"
11-
f"{modules.CONTRACT}"
12-
f"{fields.ACTION}"
13-
f"{actions.GET_ABI}"
14-
f"{fields.ADDRESS}"
15-
f"{address}"
16-
)
12+
url = f"{fields.MODULE}" f"{modules.CONTRACT}" f"{fields.ACTION}" f"{actions.GET_ABI}" f"{fields.ADDRESS}" f"{address}"
1713
return url
1814

1915
@staticmethod
2016
def get_contract_source_code(address: str) -> str:
17+
url = f"{fields.MODULE}" f"{modules.CONTRACT}" f"{fields.ACTION}" f"{actions.GET_SOURCE_CODE}" f"{fields.ADDRESS}" f"{address}"
18+
return url
19+
20+
@staticmethod
21+
def get_contract_creator_and_creation_tx_hash(addresses: List[str]) -> str:
22+
address_list = reduce(lambda w1, w2: str(w1) + "," + str(w2), addresses)
2123
url = (
2224
f"{fields.MODULE}"
2325
f"{modules.CONTRACT}"
2426
f"{fields.ACTION}"
25-
f"{actions.GET_SOURCE_CODE}"
26-
f"{fields.ADDRESS}"
27-
f"{address}"
27+
f"{actions.GET_CONTRACT_CREATION}"
28+
f"{fields.CONTRACT_ADDRESSES}"
29+
f"{address_list}"
2830
)
2931
return url

etherscan/modules/gastracker.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,5 @@ def get_est_confirmation_time(gas_price: int) -> str:
2020
@staticmethod
2121
def get_gas_oracle() -> str:
2222
# NOTE: gas_price in wei, result in seconds
23-
url = (
24-
f"{fields.MODULE}"
25-
f"{modules.GASTRACKER}"
26-
f"{fields.ACTION}"
27-
f"{actions.GAS_ORACLE}"
28-
)
23+
url = f"{fields.MODULE}" f"{modules.GASTRACKER}" f"{fields.ACTION}" f"{actions.GAS_ORACLE}"
2924
return url

0 commit comments

Comments
 (0)