TransactionBuilder#
tradeexecutor.ethereum.tx.TransactionBuilder class.
- class TransactionBuilder[source]#
Bases:
object
Create transactions from the hot wallet and store them in the state.
Creates trackable transactions. TransactionHelper is initialised at the start of the each cycle.
Transaction builder can prepare multiple transactions in one batch. For all tranactions, we use the previously prepared gas price information.
- __init__(web3, hot_wallet, gas_fees)[source]#
- Parameters
web3 (Web3) –
hot_wallet (HotWallet) –
gas_fees (GasPriceSuggestion) –
Methods
__init__
(web3, hot_wallet, gas_fees)as_signed_tx
(tx)Get a transaction as a format ready to broadcast.
broadcast
(tx)Broadcast the transaction.
Watch multiple transactions executed at parallel.
create_transaction
(contract, ...)Create a trackable transaction for the trade executor state.
Get raw transaction data out from the signed tx bytes.
sign_transaction
(args_bound_func, gas_limit)Createa a signed tranaction and set up tx broadcast parameters.
- __init__(web3, hot_wallet, gas_fees)[source]#
- Parameters
web3 (Web3) –
hot_wallet (HotWallet) –
gas_fees (GasPriceSuggestion) –
- sign_transaction(args_bound_func, gas_limit)[source]#
Createa a signed tranaction and set up tx broadcast parameters.
- Parameters
args_bound_func (ContractFunction) – Web3 function thingy
gas_limit (int) – Max gas per this transaction
- Return type
- create_transaction(contract, function_selector, args, gas_limit)[source]#
Create a trackable transaction for the trade executor state.
Sets up the state management for the transaction
Creates the signed transaction from the hot wallet
- Parameters
- Return type
- broadcast(tx)[source]#
Broadcast the transaction.
- Returns
tx_hash
- Parameters
tx (BlockchainTransaction) –
- Return type
HexBytes
- static decode_transaction(tx)[source]#
Get raw transaction data out from the signed tx bytes.
- Parameters
tx (BlockchainTransaction) –
- Return type
- static as_signed_tx(tx)[source]#
Get a transaction as a format ready to broadcast.
- Parameters
tx (BlockchainTransaction) –
- Return type
SignedTransaction
- static broadcast_and_wait_transactions_to_complete(web3, txs, confirmation_block_count=0, max_timeout=datetime.timedelta(seconds=300), poll_delay=datetime.timedelta(seconds=1), revert_reasons=False)[source]#
Watch multiple transactions executed at parallel.
Modifies the given transaction objects in-place and updates block inclusion and succeed status.
- Parameters
web3 (Web3) –
txs (List[BlockchainTransaction]) –