本文整理汇总了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)
示例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