Typed Transactions

Typed Transaction Base

class eth_account.typed_transactions.typed_transaction.TypedTransaction(transaction_type: int, transaction: _TypedTransactionImplementation)

Bases: object

Represents a Typed Transaction as per EIP-2718. The currently supported Transaction Types are:

  • EIP-2930’s AccessListTransaction

  • EIP-1559’s DynamicFeeTransaction

  • EIP-4844’s BlobTransaction

as_dict() Dict[str, Any]

Returns this transaction as a dictionary.

property blob_data: BlobPooledTransactionData | None

Returns the blobs associated with this transaction.

encode() bytes

Encodes this TypedTransaction and returns it as bytes.

The transaction format follows EIP-2718’s typed transaction format (TransactionType || TransactionPayload). Note that we delegate to a transaction type’s payload() method as the EIP-2718 does not prescribe a TransactionPayload format, leaving types free to implement their own encoding.

classmethod from_bytes(encoded_transaction: HexBytes) TypedTransaction

Builds a TypedTransaction from a signed encoded transaction.

classmethod from_dict(dictionary: Dict[str, Any], blobs: Sequence[bytes | HexBytes] | None = None) TypedTransaction

Builds a TypedTransaction from a dictionary. Verifies the dictionary is well formed.

hash() bytes

Hashes this TypedTransaction to prepare it for signing.

As per the EIP-2718 specifications, the hashing format is dictated by the transaction type itself, and so we delegate the call. Note that the return type will be bytes.

vrs() Tuple[int, int, int]

Returns (v, r, s) if they exist.

Access List Transaction

class eth_account.typed_transactions.access_list_transaction.AccessListTransaction(dictionary: Dict[str, Any])

Bases: _TypedTransactionImplementation

Represents an access list transaction per EIP-2930.

as_dict() Dict[str, Any]

Returns this transaction as a dictionary.

classmethod assert_valid_fields(dictionary: Dict[str, Any]) None
classmethod from_bytes(encoded_transaction: HexBytes) AccessListTransaction

Builds an AccessListTransaction from a signed encoded transaction.

classmethod from_dict(dictionary: Dict[str, Any], blobs: Sequence[bytes | HexBytes] | None = None) AccessListTransaction

Builds an AccessListTransaction from a dictionary. Verifies that the dictionary is well formed.

hash() bytes

Hashes this AccessListTransaction to prepare it for signing. As per the EIP-2930 specifications, the signature is a secp256k1 signature over keccak256(0x01 || rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList])).

payload() bytes

Returns this transaction’s payload as bytes.

Here, the transaction payload is:

TransactionPayload = rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList, signatureYParity, signatureR, signatureS])

signature_fields = (('v', <rlp.sedes.big_endian_int.BigEndianInt object>), ('r', <rlp.sedes.big_endian_int.BigEndianInt object>), ('s', <rlp.sedes.big_endian_int.BigEndianInt object>))
transaction_field_defaults = {'accessList': [], 'chainId': 0, 'data': b'', 'to': b'', 'type': b'0x1', 'value': 0}
transaction_type = 1
unsigned_transaction_fields = (('chainId', <rlp.sedes.big_endian_int.BigEndianInt object>), ('nonce', <rlp.sedes.big_endian_int.BigEndianInt object>), ('gasPrice', <rlp.sedes.big_endian_int.BigEndianInt object>), ('gas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('to', <rlp.sedes.binary.Binary object>), ('value', <rlp.sedes.big_endian_int.BigEndianInt object>), ('data', <rlp.sedes.binary.Binary object>), ('accessList', <rlp.sedes.lists.CountableList object>))
vrs() Tuple[int, int, int]

Returns (v, r, s) if they exist.

Dynamic Fee Transaction

class eth_account.typed_transactions.dynamic_fee_transaction.DynamicFeeTransaction(dictionary: Dict[str, Any])

Bases: _TypedTransactionImplementation

Represents a dynamic fee transaction access per EIP-1559.

as_dict() Dict[str, Any]

Returns this transaction as a dictionary.

classmethod assert_valid_fields(dictionary: Dict[str, Any]) None
classmethod from_bytes(encoded_transaction: HexBytes) DynamicFeeTransaction

Builds a DynamicFeeTransaction from a signed encoded transaction.

classmethod from_dict(dictionary: Dict[str, Any], blobs: Sequence[bytes | HexBytes] | None = None) DynamicFeeTransaction

Builds a DynamicFeeTransaction from a dictionary. Verifies that the dictionary is well formed.

hash() bytes

Hashes this DynamicFeeTransaction to prepare it for signing. As per the EIP-1559 specifications, the signature is a secp256k1 signature over keccak256(0x02 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList]))

payload() bytes

Returns this transaction’s payload as bytes.

Here, the transaction payload is:

TransactionPayload = rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, signatureYParity, signatureR, signatureS])

signature_fields = (('v', <rlp.sedes.big_endian_int.BigEndianInt object>), ('r', <rlp.sedes.big_endian_int.BigEndianInt object>), ('s', <rlp.sedes.big_endian_int.BigEndianInt object>))
transaction_field_defaults = {'accessList': [], 'chainId': 0, 'data': b'', 'to': b'', 'type': b'0x2', 'value': 0}
transaction_type = 2
unsigned_transaction_fields = (('chainId', <rlp.sedes.big_endian_int.BigEndianInt object>), ('nonce', <rlp.sedes.big_endian_int.BigEndianInt object>), ('maxPriorityFeePerGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('maxFeePerGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('gas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('to', <rlp.sedes.binary.Binary object>), ('value', <rlp.sedes.big_endian_int.BigEndianInt object>), ('data', <rlp.sedes.binary.Binary object>), ('accessList', <rlp.sedes.lists.CountableList object>))
vrs() Tuple[int, int, int]

Returns (v, r, s) if they exist.

Blob Transaction

class eth_account.typed_transactions.blob_transactions.blob_transaction.BlobTransaction(dictionary: Dict[str, Any], blobs: Sequence[bytes | HexBytes] | None = None)

Bases: _TypedTransactionImplementation

Represents a blob transaction as per EIP-4844.

as_dict() Dict[str, Any]

Returns this transaction as a dictionary.

classmethod assert_valid_fields(dictionary: Dict[str, Any], has_blobs: bool = False) None
blob_data: BlobPooledTransactionData | None = None
classmethod from_bytes(encoded_transaction: HexBytes) BlobTransaction

Builds a BlobTransaction from a signed encoded transaction.

classmethod from_dict(dictionary: Dict[str, Any], blobs: Sequence[bytes | HexBytes] | None = None) BlobTransaction

Builds a BlobTransaction from a dictionary. Verifies that the dictionary is well-formed.

hash() bytes

Keccak256 hash of the BlobTransaction to prepare it for signing. As per the EIP-4844 specifications, the signature is a secp256k1 signature over keccak256(0x03 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, maxFeePerBlobGas, blobVersionedHashes])).

payload() bytes

Returns this transaction’s payload as bytes.

Here, the transaction payload is:

TransactionPayload = rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, maxFeePerBlobGas, blobVersionedHashes, signatureYParity, signatureR, signatureS])

signature_fields = (('v', <rlp.sedes.big_endian_int.BigEndianInt object>), ('r', <rlp.sedes.big_endian_int.BigEndianInt object>), ('s', <rlp.sedes.big_endian_int.BigEndianInt object>))
transaction_field_defaults = {'accessList': [], 'chainId': 0, 'data': b'', 'to': b'', 'type': b'0x3', 'value': 0}
transaction_type = 3
unsigned_transaction_fields = (('chainId', <rlp.sedes.big_endian_int.BigEndianInt object>), ('nonce', <rlp.sedes.big_endian_int.BigEndianInt object>), ('maxPriorityFeePerGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('maxFeePerGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('gas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('to', <rlp.sedes.binary.Binary object>), ('value', <rlp.sedes.big_endian_int.BigEndianInt object>), ('data', <rlp.sedes.binary.Binary object>), ('accessList', <rlp.sedes.lists.CountableList object>), ('maxFeePerBlobGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('blobVersionedHashes', <rlp.sedes.lists.CountableList object>))
vrs() Tuple[int, int, int]

Returns (v, r, s) if they exist.