当前位置: 首页>>代码示例>>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;未经允许,请勿转载。