Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7216fdb

Browse files
author
guochijun
committed
update: more api
1 parente059d7c commit7216fdb

File tree

12 files changed

+59
-8
lines changed

12 files changed

+59
-8
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ docs
1515

1616
# eggs
1717
*egg*
18+
build/

‎etherscan/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
from .modules.statsimportStatsasstats
99
from .modules.tokensimportTokensastokens
1010
from .modules.transactionsimportTransactionsastransactions
11+
from .modules.logimportLogaslog

‎etherscan/configs/MAIN-stable.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@
153153
"address":"0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"
154154
}
155155
},
156+
"get_contract_creator":{
157+
"module":"contracts",
158+
"kwargs": {
159+
"addresses": ["0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413"]
160+
}
161+
},
156162
"get_contract_execution_status": {
157163
"module":"transactions",
158164
"kwargs": {
@@ -462,5 +468,11 @@
462468
"end_date":"2019-02-28",
463469
"sort":"asc"
464470
}
471+
},
472+
"get_log": {
473+
"module":"log",
474+
"kwargs": {
475+
"params":"&fromBlock=12878196&toBlock=17868234&page=10&offset=1000&topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f16"
476+
}
465477
}
466478
}

‎etherscan/enums/actions_enum.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class ActionsEnum:
5050
GET_BLOCK_REWARD:str="getblockreward"
5151
GET_MINED_BLOCKS:str="getminedblocks"
5252
GET_SOURCE_CODE:str="getsourcecode"
53+
GET_CTEATOR:str="getcontractcreation"
5354
GET_STATUS:str="getstatus"
5455
GET_TX_RECEIPT_STATUS:str="gettxreceiptstatus"
5556
TOKEN_BALANCE_HISTORY:str="tokenbalancehistory"
@@ -61,3 +62,4 @@ class ActionsEnum:
6162
TOKENTX:str="tokentx"
6263
TXLIST_INTERNAL:str="txlistinternal"
6364
TXLIST:str="txlist"
65+
GET_LOG:str="getLogs"

‎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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ class ModulesEnum:
1111
STATS:str="stats"
1212
TOKEN:str="token"
1313
TRANSACTION:str="transaction"
14+
LOG:str="logs"
1415

‎etherscan/etherscan.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,35 @@
1010

1111

1212
classEtherscan:
13-
def__new__(cls,api_key:str,net:str="MAIN"):
13+
def__new__(cls,api_key:str,net:str="MAIN",proxies:object={}):
1414
withresources.path(configs,f"{net.upper()}-stable.json")aspath:
1515
config_path=str(path)
16-
returncls.from_config(api_key=api_key,config_path=config_path,net=net)
16+
returncls.from_config(api_key=api_key,config_path=config_path,net=net,proxies=proxies)
1717

1818
@staticmethod
1919
def__load_config(config_path:str)->dict:
2020
withopen(config_path,"r")asf:
2121
returnjson.load(f)
2222

2323
@staticmethod
24-
def__run(func,api_key:str,net:str):
24+
def__run(func,api_key:str,net:str,proxies:object):
2525
defwrapper(*args,**kwargs):
2626
url= (
2727
f"{fields.PREFIX.format(net.lower()).replace('-main','')}"
2828
f"{func(*args,**kwargs)}"
2929
f"{fields.API_KEY}"
3030
f"{api_key}"
3131
)
32-
r=requests.get(url,headers={"User-Agent":""})
32+
r=requests.get(url,headers={"User-Agent":""},proxies=proxies)
3333
returnparser.parse(r)
3434

3535
returnwrapper
3636

3737
@classmethod
38-
deffrom_config(cls,api_key:str,config_path:str,net:str):
38+
deffrom_config(cls,api_key:str,config_path:str,net:str,proxies:object):
3939
config=cls.__load_config(config_path)
4040
forfunc,vinconfig.items():
4141
ifnotfunc.startswith("_"):# disabled if _
4242
attr=getattr(getattr(etherscan,v["module"]),func)
43-
setattr(cls,func,cls.__run(attr,api_key,net))
43+
setattr(cls,func,cls.__run(attr,api_key,net,proxies))
4444
returncls

‎etherscan/modules/accounts.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def get_internal_txs_by_block_range_paginated(
170170

171171
@staticmethod
172172
defget_erc20_token_transfer_events_by_address(
173-
address:str,startblock:int,endblock:int,sort:str,
173+
address:str,startblock:int,endblock:int,sort:str,contract_address:str=None
174174
)->str:
175175
# NOTE: Returns the last 10k events
176176
url= (
@@ -180,6 +180,8 @@ def get_erc20_token_transfer_events_by_address(
180180
f"{actions.TOKENTX}"
181181
f"{fields.ADDRESS}"
182182
f"{address}"
183+
f"{fields.CONTRACT_ADDRESSifcontract_addressisnotNoneelse''}"
184+
f"{contract_addressifcontract_addressisnotNoneelse''}"
183185
f"{fields.START_BLOCK}"
184186
f"{str(startblock)}"
185187
f"{fields.END_BLOCK}"

‎etherscan/modules/contracts.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,15 @@ def get_contract_source_code(address: str) -> str:
2727
f"{address}"
2828
)
2929
returnurl
30+
31+
@staticmethod
32+
defget_contract_creator(addresses:list)->str:
33+
url= (
34+
f"{fields.MODULE}"
35+
f"{modules.CONTRACT}"
36+
f"{fields.ACTION}"
37+
f"{actions.GET_CTEATOR}"
38+
f"{fields.CONTRACT_ADDRESSES}"
39+
f"{addresses}"
40+
)
41+
returnurl

‎etherscan/modules/log.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
frometherscan.enums.actions_enumimportActionsEnumasactions
2+
frometherscan.enums.fields_enumimportFieldsEnumasfields
3+
frometherscan.enums.modules_enumimportModulesEnumasmodules
4+
5+
6+
classLog:
7+
@staticmethod
8+
defget_log(params:str)->str:
9+
url= (
10+
f"{fields.MODULE}"
11+
f"{modules.LOG}"
12+
f"{fields.ACTION}"
13+
f"{actions.GET_LOG}"
14+
f"{params}"
15+
)
16+
returnurl

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp