示例#1
0
def update(self):
    logger = self.get_logger()

    try:
        api = Tokens(
            contract_address=TETHER_CONTRACT_ADDRESS,
            api_key=s.ETHERSCAN_API_KEY,
        )
        Tether(
            total_supply_eth=int(api.get_total_supply()) / 10 ** 6,
            num_holders_eth=_get_tether_num_holders(),
        ).save()

    except Exception as error:
        logger.error("tether error: {}".format(str(error)))
        self.update_state(state=states.FAILURE, meta=str(error))
        raise Ignore()
示例#2
0
def get_balance(wallet_type, address, contract_address=None, api_key=None):
    """Get the balance of a single wallet."""

    value = 0
    if wallet_type == 'ETH':
        account = Account(address=address, api_key=api_key)
        value += float(account.get_balance()) / 1000000000000000000
    elif wallet_type == 'EOS':
        api = Tokens(contract_address=contract_address, api_key=api_key)
        value += float(api.get_token_balance(address=address)) / 1000000000000000000
    elif wallet_type == 'XRB':
        # hardcoded for now...
        value = 10.179600
    else:
        value += blockcypher.get_total_balance(address, coin_symbol=wallet_type.lower()) / 100000000
    
    return value
示例#3
0
def main():

    if len(sys.argv) < 2:
    	 print("usage: " + os.path.basename(__file__) + " user_wallet erc_20_contract_address")
    	 print("Find an ether wallet address. Whales can be found in the token holders section")
    	 sys.exit(1)
    elif len(sys.argv) < 3:
    	print("usage: " + os.path.basename(__file__) + " user_wallet ERC20_CONTRACT_ADDRESS") 
    	print("Find the ERC20 contract address. Click the token name in token transactions.")
    	sys.exit(1)
    else:
    	wallet_addy = str(sys.argv[1])
    	token_addy = str(sys.argv[2])
    	api = Tokens(contract_address=token_addy, api_key=key)
    	balance = api.get_token_balance(address=wallet_addy)
    	balance = int(balance) 

    	if (balance > 0):
           balance = balance / 1000000000000000000

    print(balance)
from etherscan.tokens import Tokens
from EtherscanAPI import EtherscanAPI

import os
import json

DATA_DIR = './TokenData'
api = EtherscanAPI()
API_KEY = api.key
api._create_data_folder(DATA_DIR)

if __name__ == '__main__':
    test_address = '0xe04f27eb70e025b78871a2ad7eabe85e61212761'
    test_contract_address = '0x57d90b64a1a57749b0f932f1a3395792e12e7055'

    api = Tokens(contract_address=test_contract_address, api_key=API_KEY)
    balance = api.get_token_balance(address=test_address)
    print(balance)

    api = Tokens(contract_address=test_contract_address, api_key=API_KEY)
    supply = api.get_total_supply()
    print(supply)
from etherscan.tokens import Tokens
import json

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

#  tokenname options are:
#     DGD
#     MKR
#     TheDAO
address = '0x0a869d79a7052c7f1b55a8ebabbea3420f0d1e13'
api = Tokens(tokenname='TheDAO', api_key=key)
balance = api.get_token_balance(address=address)
print(balance)
示例#6
0
from etherscan.tokens import Tokens
import json

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

address = '0xe04f27eb70e025b78871a2ad7eabe85e61212761'
api = Tokens(contract_address='0x57d90b64a1a57749b0f932f1a3395792e12e7055',
             api_key=key)
balance = api.get_token_balance(address=address)
print(balance)
示例#7
0
                                                       index=index)
transaction = api.get_transaction_by_hash(tx_hash=TX_HASH)
count = api.get_transaction_count(address)
receipt = api.get_transaction_receipt(TX_HASH)
uncles = api.get_uncle_by_blocknumber_index(block_number=block_numb,
                                            index=index)

# Stats

api = Stats(api_key=key)

last_price = api.get_ether_last_price()
supply = api.get_total_ether_supply()

# Tokens

address = '0xe04f27eb70e025b78871a2ad7eabe85e61212761'
contract_address = '0x57d90b64a1a57749b0f932f1a3395792e12e7055'
api = Tokens(contract_address=contract_address, api_key=key)

balance = api.get_token_balance(address=address)
supply = api.get_total_supply()

# Transactions

TX_HASH = '0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a'
api = Transactions(api_key=key)

status = api.get_status(tx_hash=TX_HASH)
receipt_status = api.get_tx_receipt_status(tx_hash=TX_HASH)
示例#8
0
 def test_get_token_balance(self):
     api = Tokens(contract_address=CONTRACT_ADDRESS, api_key=API_KEY)
     self.assertEqual(api.get_token_balance(ADDRESS), ELCOIN_TOKEN_BALANCE)
示例#9
0
# Proxies
api = Proxies(api_key=key)
block = api.get_block_by_number(5747732)
print('\nProxies:')
print(block['number'])

block = api.get_most_recent_block()
print(int(block, 16))

# Stats
api = Stats(api_key=key)
last_price = api.get_ether_last_price()
last_price_table = pd.DataFrame(last_price, index=[0])
print('\nLast ether price')
print(last_price_table)

# call with default address, The DAO
api = Stats(api_key=key)
supply = api.get_total_ether_supply()
print('Total ether supply:')
print(supply)

# Tokens
address = '0xe04f27eb70e025b78871a2ad7eabe85e61212761'
api = Tokens(contract_address='0x57d90b64a1a57749b0f932f1a3395792e12e7055',
             api_key=key)
balance = api.get_token_balance(address=address)
print('\nTokens:')
print('Balance:', balance)
from etherscan.tokens import Tokens
import json

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

#  tokenname options are:
#     DGD
#     MKR
#     TheDAO
api = Tokens(tokenname='SNT', api_key=key)
supply = api.get_total_supply()
print(supply)
示例#11
0
def test_get_token_balance():
    api = Tokens(tokenname=TOKEN_NAME, api_key=API_KEY)
    assert (api.get_token_balance(ADDRESS) == DGD_TOKEN_BALANCE)
示例#12
0
def test_get_token_supply():
    api = Tokens(tokenname=TOKEN_NAME, api_key=(API_KEY))
    assert (api.get_total_supply() == DGD_TOKEN_SUPPLY)
示例#13
0
 def test_get_token_balance(self):
     api = Tokens(contract_address=CONTRACT_ADDRESS, api_key=API_KEY)
     self.assertEqual(api.get_token_balance(ADDRESS), ELCOIN_TOKEN_BALANCE)
示例#14
0
 def test_get_token_supply(self):
     api = Tokens(contract_address=CONTRACT_ADDRESS, api_key=(API_KEY))
     self.assertEqual(api.get_total_supply(), ELCOIN_TOKEN_SUPPLY)
示例#15
0
def test_get_token_supply():
    api = Tokens(contract_address=CONTRACT_ADDRESS, api_key=(API_KEY))
    assert (api.get_total_supply() == ELCOIN_TOKEN_SUPPLY)
示例#16
0
def test_get_token_balance():
    api = Tokens(contract_address=CONTRACT_ADDRESS, api_key=API_KEY)
    assert(api.get_token_balance(ADDRESS) == ELCOIN_TOKEN_BALANCE)
示例#17
0
 def test_get_token_supply(self):
     api = Tokens(contract_address=CONTRACT_ADDRESS, api_key=(API_KEY))
     self.assertEqual(api.get_total_supply(), ELCOIN_TOKEN_SUPPLY)