BlockchainTransaction#
tradeexecutor.state.blockhain_transaction.BlockchainTransaction class.
- class BlockchainTransaction[source]#
Bases:
object
A stateful blockchain transaction.
The state tracks a transaction over its life cycle
Transactions are part of a larger logical operation (a trade)
Transactions can be resolved either to success or failed
Transaction information is easily exported to the frontend
Transaction has (rough) four phases
Preparation
Signing
Broadcast
Confirmation
- __init__(chain_id=None, from_address=None, contract_address=None, function_selector=None, args=None, tx_hash=None, nonce=None, details=None, signed_bytes=None, broadcasted_at=None, included_at=None, block_number=None, block_hash=None, status=None, realised_gas_units_consumed=None, realised_gas_price=None, revert_reason=None)#
- Parameters
- Return type
None
Methods
__init__
([chain_id, from_address, ...])from_dict
(kvs, *[, infer_missing])from_json
(s, *[, parse_float, parse_int, ...])Return the transaction object as it would be in web3.py.
Transaction is success if it's succeed flag has been set.
schema
(*[, infer_missing, only, exclude, ...])set_broadcast_information
(nonce, tx_hash, ...)Update the information we are going to use to broadcast the transaction.
set_confirmation_information
(ts, ...[, ...])Update the information we are going to use to broadcast the transaction.
set_target_information
(chain_id, ...)Update the information on which transaction we are going to perform.
to_dict
([encode_json])to_json
(*[, skipkeys, ensure_ascii, ...])Attributes
Arguments we passed to the smart contract function
Block has of the transaction where the executor saw the inclusion
Block number when this transaction was included in a block
When this transaction was broadcasted
Chain id from https://github.com/ethereum-lists/chains
Contract we called.
Raw Ethereum transaction dict.
TODO: Part of signed bytes.
Function we called
Block timestamp when this tranasction was included in a block
Blockchain bookkeeping
Gas price for the tx in gwei
Gas consumed by the tx
The transaction revert reason if we manage to extract it
Raw bytes of the signed transaction
status from the tx receipt.
Blockchain bookkeeping
- chain_id: Optional[int] = None#
Chain id from https://github.com/ethereum-lists/chains
- included_at: Optional[datetime] = None#
Block timestamp when this tranasction was included in a block
- get_transaction()[source]#
Return the transaction object as it would be in web3.py.
Needed for
analyse_trade_by_receipt()
. This will reconstructTypedTransaction
instance from the raw signed transaction bytes. The object will have a dict containing “data” field which we can then use for the trade analysis.- Return type
- set_target_information(chain_id, contract_address, function_selector, args, details)[source]#
Update the information on which transaction we are going to perform.
- set_broadcast_information(nonce, tx_hash, signed_bytes)[source]#
Update the information we are going to use to broadcast the transaction.
- set_confirmation_information(ts, block_number, block_hash, realised_gas_units_consumed, realised_gas_price, status, revert_reason=None)[source]#
Update the information we are going to use to broadcast the transaction.
- __init__(chain_id=None, from_address=None, contract_address=None, function_selector=None, args=None, tx_hash=None, nonce=None, details=None, signed_bytes=None, broadcasted_at=None, included_at=None, block_number=None, block_hash=None, status=None, realised_gas_units_consumed=None, realised_gas_price=None, revert_reason=None)#
- Parameters
- Return type
None