本文整理匯總了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