get_tx_broadcast_data
Documentation for eth_defi.tx.get_tx_broadcast_data function.
- get_tx_broadcast_data(signed_tx)
Get raw transaction bytes with compatibility for attribute name changes.
eth_account changed rawTransaction to raw_transaction in newer versions. This function handles both attribute names.
- Parameters
signed_tx (SignedTransaction | SignedTransactionWithNonce) – Signed transaction object from SignedTransaction | SignedTransactionWithNonce
- Returns
Raw transaction bytes ready for broadcasting to the network
- Return type
HexBytes
- Raises
AttributeError – If the signed transaction object has neither ‘raw_transaction’ nor ‘rawTransaction’ attribute
Example:
from eth_defi.compat import get_tx_broadcast_data # Works with both old and new eth_account versions raw_bytes = get_tx_broadcast_data(signed_tx) tx_hash = web3.eth.send_raw_transaction(raw_bytes)