當前位置: 首頁>>代碼示例>>Python>>正文


Python Web3.fromWei方法代碼示例

本文整理匯總了Python中web3.Web3.fromWei方法的典型用法代碼示例。如果您正苦於以下問題:Python Web3.fromWei方法的具體用法?Python Web3.fromWei怎麽用?Python Web3.fromWei使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在web3.Web3的用法示例。


在下文中一共展示了Web3.fromWei方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_gas_reserve

# 需要導入模塊: from web3 import Web3 [as 別名]
# 或者: from web3.Web3 import fromWei [as 別名]
def check_gas_reserve(raiden):
    """ Check periodically for gas reserve in the account """
    while True:
        has_enough_balance, estimated_required_balance = gas_reserve.has_enough_gas_reserve(
            raiden,
            channels_to_open=0,
        )
        estimated_required_balance_eth = Web3.fromWei(estimated_required_balance, 'ether')

        if not has_enough_balance:
            log.info('Missing gas reserve', required_wei=estimated_required_balance)
            click.secho(
                (
                    'WARNING\n'
                    "Your account's balance is below the estimated gas reserve of "
                    f'{estimated_required_balance_eth} eth. This may lead to a loss of '
                    'of funds because your account will be unable to perform on-chain '
                    'transactions. Please add funds to your account as soon as possible.'
                ),
                fg='red',
            )

        gevent.sleep(CHECK_GAS_RESERVE_INTERVAL)
開發者ID:hackaugusto,項目名稱:raiden,代碼行數:25,代碼來源:tasks.py

示例2: getBalance

# 需要導入模塊: from web3 import Web3 [as 別名]
# 或者: from web3.Web3 import fromWei [as 別名]
 def getBalance(self):
     wei_balance = self.web3.eth.getBalance(self.address)
     ether_balance = Web3.fromWei(wei_balance, unit='ether')
     return ether_balance
開發者ID:nud3l,項目名稱:agent-local,代碼行數:6,代碼來源:ContractHandler.py


注:本文中的web3.Web3.fromWei方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。