Exemplo n.º 1
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
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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']

#  tokenname options are:
#     DGD
#     MKR
#     TheDAO
address = '0x0a869d79a7052c7f1b55a8ebabbea3420f0d1e13'
api = Tokens(tokenname='TheDAO', api_key=key)
balance = api.get_token_balance(address=address)
print(balance)
Exemplo n.º 5
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)
Exemplo n.º 6
0
def test_get_token_balance():
    api = Tokens(tokenname=TOKEN_NAME, api_key=API_KEY)
    assert (api.get_token_balance(ADDRESS) == DGD_TOKEN_BALANCE)
Exemplo n.º 7
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)