Example #1
0
 def get_balance(configuration, token_symbol=None):
     """
     Get balance from account address.
     :param configuration: loaded configuration file instance
     :param token_symbol: None for ETH, ERC20 symbol for other tokens
     :return:
     """
     wallet_address = Wallet(configuration).get_address()
     if token_symbol is None:
         balance = Wallet(configuration).get_balance(wallet_address)
     else:
         contract_address = configuration.contracts[token_symbol]
         contract = Contract(configuration, contract_address)
         balance = contract.get_balance(wallet_address)
     return balance, wallet_address
Example #2
0
 def get_balance(configuration, token_symbol=None):
     """
     Get balance from account address.
     :param configuration: loaded configuration file instance
     :param token_symbol: None for ETH, ERC20 symbol for other tokens
     :return:
     """
     wallet_address = Wallet(configuration).get_address()
     if token_symbol is None:
         balance = Wallet(configuration).get_balance(wallet_address)
     else:
         try:  # check if token is added to the wallet
             contract_address = configuration.contracts[token_symbol]
         except KeyError:
             raise ERC20NotExistsException()
         contract = Contract(configuration, contract_address)
         balance = contract.get_balance(wallet_address)
     return balance, wallet_address