get_pls_balance

Function

def get_pls_balance(address, decimals=False, attempts=18):
    while attempts > 0:
        try:
            balance = web3.eth.get_balance(address)
        except Exception as e:
            logging.debug(e)
            time.sleep(1)
            attempts -= 1
        else:
            if decimals:
                return balance
            else:
                return from_token_decimals(balance, 18)
    return -1

Description

  • Loop while there are attempts remaining

  • Get the PLS balance for the address

  • If decimals is set to False then add 18 decimal places

  • Return the balance