check if the actor has enough funds to deposit added

This commit is contained in:
Alexander Kolotov 2018-06-01 18:44:42 +03:00
parent 1e6df73bbe
commit 116ab15a20
2 changed files with 5 additions and 2 deletions

View File

@ -29,8 +29,6 @@ gas_price = b.home_bridge.functions.gasPrice().call()
gas_limit = 50000
net_id = int(web3.version.network)
op_num = web3.eth.getTransactionCount(b.actor_address)
tx_templ = {
'to': b.home_bridge_address,
'gas': gas_limit,
@ -44,6 +42,11 @@ op_num = web3.eth.getTransactionCount(actor.address)
if tx_value == None:
tx_value = b.home_bridge.functions.minPerTx().call()
balance_needed = ((gas_price * gas_limit + tx_value) * tx_num)
balance_current = web3.eth.getBalance(actor.address)
if balance_needed > balance_current:
exit(f'{actor.address} balance is lower than needed ({balance_needed} > {balance_current})')
################################################################################
# Preparing batch of transactions to the bridge contract with ether sending
################################################################################