-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
68 lines (57 loc) · 1.86 KB
/
utils.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
58
59
60
61
62
63
64
65
66
67
68
import json
import os
import numpy as np
import requests
import time
#
def readJson(path: str):
with open(path, 'r', encoding='utf-8-sig') as json_file:
buffer = json.load(json_file)
return buffer
#
def saveJson(save_path, wallet_list):
with open(save_path, 'w') as json_file:
json.dump(wallet_list, json_file, indent=2)
print('saved')
#
def get_misttrack_label(coin: str, address: str) -> None:
mapping = {'BTC': 'BTC', 'ETH': 'ETH', 'TRON': 'TRX'}
api_key_mt = 'd8ab0f7a43cc49618af572fa6c5e1c0c'
url = ('https://openapi.misttrack.io/v1/address_labels?coin={}&address={}&api_key={}'
.format(mapping[coin], address, api_key_mt))
response = requests.get(url=url).json()
return response
#
def get_oklink_label(chain_name: str, address: str):
url = f"https://www.oklink.com/api/v5/explorer/address/entity-label?chainShortName={chain_name}&address={address}"
payload = ""
headers = {
'Ok-Access-Key': 'eedb6f15-f0d3-47e6-a990-6647ef636bb7'
}
response = requests.request("GET", url, headers=headers, data=payload).json()
return response
#
def func_1():
data_list = readJson(path='./label_database/tron.json')
counter = 0
total_counter = 0
for address in data_list.keys():
if data_list[address]['misttrack_label_type'] == 'defi':
response = get_oklink_label(chain_name='tron', address=address)
if len(response['data']) > 0:
counter += 1
total_counter += 1
time.sleep(1)
print(data_list[address])
print('\n')
print(response)
print(f'counter: {counter}/{total_counter}')
print('-' * 50)
#
if __name__ == '__main__':
response = get_misttrack_label(coin='ETH', address='0x7a250d5630b4cf539739df2c5dacb4c659f2488d')
print(response)
#
'''
labeld: 413/2656
'''