Esempio n. 1
0
def main():
    with open('../api_key.json', mode='r') as key_file:
        key = json.loads(key_file.read())['key']
    
    # get steven's contract initialization input data as a reference
    api = Proxies(api_key=key)
    transaction_1 = api.get_transaction_by_hash(
    	tx_hash='0x5920ad6d2c1caa27dae2e85b4764a28c7665d8f4ecfc17150c0abd9f26cb2ca4')
    target_input_1 = transaction_1['input']
    transaction_2 = api.get_transaction_by_hash(
    	tx_hash='0x881bd88aac40ba6f49e7e6130e7bafc154a9e918b6f792742ff10cf731309cce')
    target_input_2 = transaction_2['input']
    
    target_input = longestSubstringFinder(target_input_1, target_input_2)
    # Search over all Tx within all blocks between 6pm and 7pm local time
    #block = api.get_block_by_number(3638953)
    #print(block.keys())
    
    hash_list = []
    block_number_all = list(range(3626750,3626760))
    for block_number in block_number_all:
        block = api.get_block_by_number(block_number)
        for transaction in block['transactions']:
            if transaction['input'][0:5960] == target_input:
                hash_list.append(transaction['hash'])
            
    print (hash_list)
 def test_get_most_recent_block(self):
     api = Proxies(api_key=API_KEY)
     # currently raises an exception even though it should not, see:
     # https://github.com/corpetty/py-etherscan-api/issues/32
     most_recent = int(api.get_most_recent_block(), 16)
     print(most_recent)
     p = re.compile('^[0-9]{7}$')
     self.assertTrue(p.match(str(most_recent)))
Esempio n. 3
0
from os.path import isfile
from requests import HTTPError
from etherscan.proxies import Proxies

blocks_path = "../blocks_new/"
max_files_in_dir = 5000
files_in_dir = 0
current_dir = 0

sleep_time = 0.2
first_block_num = 4650000
last_block_num = 4825000

with open('api_key.json', mode='r') as key_file:
    key = loads(key_file.read())['key']
api = Proxies(api_key=key)

try:
    mkdir(blocks_path + str(current_dir))
except OSError:
    print('Failed to create directory %s' % blocks_path + str(current_dir))
else:
    print('Created directory %s successfully' % blocks_path + str(current_dir))

print("Downloading transactions for blocks: {} to {}".format(
    first_block_num, last_block_num))
for i in tqdm(range(4708444, last_block_num + 1)):
    try:
        block = api.get_block_by_number(i)
        minified_txs = []
        for tx in block['transactions']:
 def __init__(self, key):
     self.api_key = key
     self.api = Proxies(api_key=key)
Esempio n. 5
0
def test_get_most_recent_block():
    api = Proxies(api_key=API_KEY)
    most_recent = int(api.get_most_recent_block(), 16)
    print(most_recent)
    p = re.compile('^[0-9]{7}$')
    assert (p.match(str(most_recent)))
Esempio n. 6
0
 def __init__(self):
     super().__init__()
     self.api = Proxies(api_key=self.key)
     self._create_data_folder(DATA_DIR)