Transactions
BaseTransactionMethods
- class eth.rlp.transactions.BaseTransactionMethods
- gas_used_by(computation: ComputationAPI) int
Return the gas used by the given computation. In Frontier, for example, this is sum of the intrinsic cost and the gas used during computation.
- validate() None
Hook called during instantiation to ensure that all transaction parameters pass validation rules.
BaseTransactionFields
- class eth.rlp.transactions.BaseTransactionFields(*args, **kwargs)
- property data
- property gas
- property gas_price
Will raise
AttributeError
if get or set on a 1559 transaction.
- property hash: Hash32
Return the hash of the transaction.
- property nonce
- property r
- property s
- property to
- property v
- property value
BaseTransaction
- class eth.rlp.transactions.BaseTransaction(*args, **kwargs)
- classmethod decode(encoded: bytes) SignedTransactionAPI
This decodes a transaction that is encoded to either a typed transaction or a legacy transaction, or even the payload of one of the transaction types. It assumes that typed transactions are not rlp-encoded first.
If dealing with an object that is rlp encoded first, then use this instead:
rlp.decode(encoded, sedes=TransactionBuilderAPI)
For example, you may receive a list of transactions via a devp2p request. Each transaction is either a (legacy) rlp list, or a (new-style) bytestring. Even if the transaction is a bytestring, it’s wrapped in an rlp bytestring, in that context. New-style transactions will not be wrapped in an RLP bytestring in other contexts. They will just be an EIP-2718 type-byte plus payload of concatenated bytes, which cannot be decoded as RLP. An example context for this is calculating the transaction root hash.
- encode() bytes
This encodes a transaction, no matter if it’s: a legacy transaction, a typed transaction, or the payload of a typed transaction. See more context in decode.
- property data
- property gas
- property gas_price
Will raise
AttributeError
if get or set on a 1559 transaction.
- property nonce
- property r
- property s
- property to
- property v
In old transactions, this v field combines the y_parity bit and the chain ID. All new usages should prefer accessing those fields directly. But if you must access the original v, then you can cast to this API first (after checking that type_id is None).
- property value