Exemplo n.º 1
0
def ico_chart_data(token_name):
    key = 'F3C5GJBZ611TXR77PFERXB56R5VD1P9YUD'
    try:
        address = provider.search(token_name)['ico']
        web3 = get_web3_provider()
        account = Account(address=address, api_key=key)
        transactions = account.get_all_transactions(offset=1000,
                                                    sort='asc',
                                                    internal=True)
        data_frame = pd.DataFrame(transactions)
        data_frame = data_frame[(data_frame['isError'] != '1')]
        data_frame['datetime'] = pd.to_datetime(data_frame['timeStamp'],
                                                unit='s')
        data_frame['value'] = data_frame['value'].apply(
            lambda x: web3.fromWei(int(x), 'ether'))
        data_frame = data_frame[data_frame['value'] > 0]
        data_frame['date'] = data_frame['datetime'].dt.date
        data_frame['blockNumber'] = data_frame['blockNumber'].apply(
            lambda x: int(x))
        data_group = data_frame.groupby('blockNumber')['value',
                                                       'isError'].sum()
        data_group['index'] = data_group.index
        labels = data_group['index'].as_matrix()
        min_label = labels.min()
        max_label = labels.max()
        labels = (labels - min_label) * 100 / (max_label - min_label)
        values = data_group['value'].as_matrix()
        cumulative_values = values.cumsum()
        total = values.sum()
        cumulative_values = cumulative_values * 100 / total
        return labels, cumulative_values
    except:
        return None
Exemplo n.º 2
0
def main():

    if len(sys.argv) < 2:
        print("usage: " + os.path.basename(__file__) + " user_wallet")
        sys.exit(1)
    else:
        wallet_addy = str(sys.argv[1])
        address = wallet_addy
        api = Account(address=wallet_addy, api_key=key)
        transactions = api.get_all_transactions(offset=10000,
                                                sort='des',
                                                internal=False)
        pprint.pprint(transactions)
Exemplo n.º 3
0
from etherscan.accounts import Account
import json

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

#  address = ['0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a', '0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a']
address = '0x49edf201c1e139282643d5e7c6fb0c7219ad1db7'

api = Account(address=address, api_key=key)
transactions = api.get_all_transactions(offset=10000,
                                        sort='asc',
                                        internal=True)

print(transactions[0])
Exemplo n.º 4
0
from etherscan.accounts import Account
import json

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

#  address = ['0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a', '0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a']
address = '0x5bda447c0c2ade0a0b6daf22c88505f9e55f0c61 '

api = Account(address=address, api_key=key)
transactions = api.get_all_transactions(offset=10000, sort='asc')
print(transactions[0])
Exemplo n.º 5
0
def get_all_transactions():
    api = Account(address=ADDRESS, api_key=ether_key)
    transactions = api.get_all_transactions(offset=10000,
                                            sort='asc',
                                            internal=True)
    return transactions
from etherscan.accounts import Account
import json

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

address = '0x49edf201c1e139282643d5e7c6fb0c7219ad1db7'

api = Account(address=address, api_key=key)
transactions = api.get_all_transactions(offset=10000, sort='asc',
                                        internal=False)

print(transactions[0])
Exemplo n.º 7
0
class Accounts(EtherscanAPI):
    def __init__(self, address):
        super().__init__()
        self.address = address
        self.api = Account(address=address, api_key=self.key)
        self._create_data_folder(DATA_DIR)

    def _data_to_df_save(self, data, filename, save=False):
        df = pd.DataFrame(data)
        df['timeStamp'] = pd.to_datetime(df['timeStamp'], unit='s')
        df.set_index('timeStamp', inplace=True)

        if save:
            filepath = os.path.join(DATA_DIR, filename)
            df.to_csv(filepath)
            print('Data file saved')
        return df

    def get_balance(self):
        balance = self.api.get_balance()
        return balance

    def get_balance_multi(self):
        balances = self.api.get_balance_multiple()
        return balances

    def get_block_mined(self,
                        page=1,
                        offset=10000,
                        blocktype='blocks',
                        save=False):
        block = self.api.get_blocks_mined_page(page=page,
                                               offset=offset,
                                               blocktype=blocktype)

        filename = f'{self.address}-page{page}-offset{offset}-blocks-mined.csv'
        blocks_df = self._data_to_df_save(block, filename, save=save)
        return blocks_df

    def get_all_blocks_mined(self,
                             offset=10000,
                             blocktype='blocks',
                             save=False):
        blocks = self.api.get_all_blocks_mined(offset=offset,
                                               blocktype=blocktype)

        filename = f'{self.address}-all-blocks-mined.csv'
        blocks_df = self._data_to_df_save(blocks, filename, save=save)
        return blocks_df

    def get_all_transactions(self,
                             offset=1000,
                             sort='acs',
                             internal=False,
                             save=False):
        transactions = self.api.get_all_transactions(offset=offset,
                                                     sort=sort,
                                                     internal=internal)

        filename = f'{self.address}-all-transactions.csv'
        transac_df = self._data_to_df_save(transactions, filename, save=save)
        return transac_df

    def get_transaction_page(self,
                             page=1,
                             offset=10000,
                             sort='asc',
                             internal=False,
                             erc20=False,
                             save=True):
        transactions = self.api.get_transaction_page(page=page,
                                                     offset=offset,
                                                     sort=sort,
                                                     internal=internal,
                                                     erc20=erc20)
        transac_df = pd.DataFrame(transactions)
        transac_df['timeStamp'] = pd.to_datetime(transac_df['timeStamp'],
                                                 unit='s')
        transac_df.set_index('timeStamp', inplace=True)

        filename = f'{self.address}-page{page}-offset{offset}-transactions.csv'
        transac_df = self._data_to_df_save(transactions, filename, save=save)
        return transac_df
def get_all_transactions(address, offset, sort, internal):
    api = Account(address=address, api_key=key)
    transactions = api.get_all_transactions(offset=offset,
                                            sort=sort,
                                            internal=internal)
    print(transactions[0])