Exemplo n.º 1
0
 def add_address(self, add):
     if type(self.address) == str:
         self.address = [self.address]
     if type(add) == str:
         add = [add]
     self.address = list(set(self.address + add))
     self.api = accounts.Account(address=self.address, api_key=self.apikey)
Exemplo n.º 2
0
 def etherscan_reader(self,
                      number=10000,
                      address="0x8fFd2bD41E1AE6664FeDed043fA6fDc0AdFdA85a"):
     with open('api_key.json', mode='r') as key_file:
         key = json.loads(key_file.read())['key']
     api = accounts.Account(address=address, api_key=key)
     self.transaction = api.get_transaction_page(sort='desc', offset=number)
     self.change_dictionary()
     return self.transaction
Exemplo n.º 3
0
def get_ERC20_trans(address, key):
    api = accounts.Account(address=address, api_key=key)
    ERC20trans = api.get_transaction_page(erc20=True)
    ERC20trans = pd.DataFrame(ERC20trans)
    ERC20trans.timeStamp = ERC20trans.timeStamp.astype("int").apply(
        lambda d: datetime.utcfromtimestamp(d).strftime("%Y/%m/%d %H:%M:%S UTC"
                                                        ))
    ERC20trans.rename(columns={"timeStamp": "time"}, inplace=True)
    ERC20trans.to_csv("./ETC20_transactions.csv", index=False)
Exemplo n.º 4
0
def get_block_mine_page(address, key):
    api = accounts.Account(address=address, api_key=key)
    blocks = api.get_blocks_mined_page(page=1, offset=10)
    blocks = pd.DataFrame(blocks)
    blocks.timeStamp = blocks.timeStamp.astype("int").apply(
        lambda d: datetime.utcfromtimestamp(d).strftime("%Y/%m/%d %H:%M:%S UTC"
                                                        ))
    blocks.rename(columns={"timeStamp": "time"}, inplace=True)
    blocks.to_csv("./blocks_mined.csv", index=False)
Exemplo n.º 5
0
def get_all_address_trans_to(address):
    api = accounts.Account(address=address, api_key="DTTR16CPVKIE8XDIF4M6UB65J2X64Q77HS")
    transactions = api.get_all_transactions(offset=100, sort='asc', internal=False)
    from_address_set = set()
    for transaction in transactions:
        if "from" in transaction and transaction["from"] != address and days_to_now(transaction["timeStamp"]) <= n_days:
            from_address_set.add(transaction["from"])
    if address in from_address_set:
        from_address_set.remove(address)
    # print("find %s address trans to %s" % (len(from_address_set), address))
    return from_address_set
Exemplo n.º 6
0
def get_trans_page(address, key, page=1, offset=10):
    api = accounts.Account(address=address, api_key=key)
    trans = api.get_transaction_page(
        page=page, offset=offset
    )  #(get paginated results here) ("offset" parameter: max records to return)
    trans = pd.DataFrame(trans)
    trans.timeStamp = trans.timeStamp.astype("int").apply(
        lambda d: datetime.utcfromtimestamp(d).strftime("%Y/%m/%d %H:%M:%S UTC"
                                                        ))
    trans.rename(columns={"timeStamp": "time"}, inplace=True)
    trans.to_csv("./normal_transactions.csv", index=False)
Exemplo n.º 7
0
def update_sov_24_hours(transactions):

    api = accounts.Account(address=address, api_key=api_key)
    update = api.get_transaction_page(page=1, offset=5)

    k = 0
    while (k < 5):
        if (update[k] == transactions[len(transactions) - k]):
            k += 1
        else:
            transactions.append(update[k])
            transactions.pop(0)
            k += 1

    return transactions
Exemplo n.º 8
0
def init_sov_24_hours():

    api = accounts.Account(address=address, api_key=api_key)
    transactions_24_hours = api.get_transaction_page(offset=7500)

    i = len(transactions_24_hours)
    latest_24_hours = (int(transactions_24_hours[i - 1]['timeStamp']) -
                       twentyFourHours)

    k = 0
    while (int(transactions_24_hours[k]['timeStamp'])) < latest_24_hours:
        k += 1

    transactionsList = []
    while k < len(transactions_24_hours):
        transactionsList.append(transactions_24_hours[k])
        k += 1

    return transactionsList
Exemplo n.º 9
0
 def etherscan_reader_erc20(
         self,
         number=10000,
         address="0x8fFd2bD41E1AE6664FeDed043fA6fDc0AdFdA85a",
         full_transaction=False):
     with open('api_key.json', mode='r') as key_file:
         key = json.loads(key_file.read())['key']
     api = accounts.Account(address=address, api_key=key)
     print("bury000")
     print(api)
     self.transaction_erc20 = api.get_transaction_page(sort='desc',
                                                       offset=number,
                                                       erc20=True)
     print("burytest")
     print(self.transaction_erc20)
     transaction_action_input = api.get_transaction_page(sort='desc',
                                                         offset=number)
     self.change_dictionary_erc20(transaction_action_input,
                                  full_transaction)
     print(self.transaction_erc20)
     return self.transaction_erc20
Exemplo n.º 10
0
def latest_avg():
    api = accounts.Account(address=address, api_key=api_key)
    avg = api.get_transaction_page(page=1, offset=1)
    latest = avg[0]['gasPrice']
    return latest
Exemplo n.º 11
0
def get_contract_time(contract_adress, api_key):
    api = accounts.Account(address=contract_adress, api_key=api_key)
    time = api.get_transaction_page(page=1, offset=1, internal=True)[
        0]['timeStamp']
    return timestamp_converter(time)
Exemplo n.º 12
0
def get_all_trans(address, key):
    api = accounts.Account(address=address, api_key=key)
    api.get_all_transactions(offset=10000, sort='asc', internal=True)
Exemplo n.º 13
0
def get_bal(address, key):
    api = accounts.Account(address=address, api_key=key)
    print(api.get_balance())
Exemplo n.º 14
0
def get_mul_account_bal(addresses, key):
    api = accounts.Account(address=addresses, api_key=key)
    mult_bal = pd.DataFrame(api.get_balance_multiple())
    mult_bal.to_csv("./balances_multiple_account.csv", index=False)
Exemplo n.º 15
0
 def __init__(self, key, address):
     # Setup api for single address
     self.key = key
     self.address = address
     self.api = accounts.Account(address=address, api_key=key)
Exemplo n.º 16
0
 def __init__(self, address, api_key):
     self.address = address
     self.apikey = api_key
     self.api = accounts.Account(address=address, api_key=api_key)
     self.trans, self.mined = None, None
Exemplo n.º 17
0
import etherscan.accounts as accounts
import etherscan.proxies as proxies
import etherscan.stats as stats
import etherscan.tokens as tokens
from etherscan.contracts import Contract
#import etherscan.transactions as transactions
#from etherscan.blocks import Blocks
import json
import pandas as pd

address = '0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b'
key = '354XMWXFIA2JXKP7C64N455NX1ZNIKSH18'

#Accounts
api = accounts.Account(address=address, api_key=key)
balance = api.get_balance()
print('balance:', balance)

balance_multiple = api.get_balance_multiple()
print('balance_multiple:', balance_multiple)

#block_mined = api.get_all_blocks_mined(offset=10000, blocktype='blocks')
#print('block_mined:', block_mined)

transaction = api.get_transaction_page(page=1, offset=10)
df_transaction = pd.DataFrame(transaction)
print('transaction:', df_transaction.head())

#all_transaction = api.get_all_transactions(offset=10000, sort='asc')
#df_all_transaction = pd.DataFrame(all_transaction)
#print(all_transaction[0])