TransactionOutput

class cometa.transaction_body.transaction_output.TransactionOutput(ptr)[source]

Bases: object

Represents an output of a Cardano transaction.

A transaction output consists of: - Address: The recipient address (can be a payment key hash or script hash) - Value: The amount of ADA (in lovelace) and any multi-assets - Datum: Optional state data for Plutus scripts - Script reference: Optional reference to a script in another output

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

TransactionOutput

__exit__(exc_type, exc_val, exc_tb)[source]
Return type:

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod new(address, amount)[source]

Creates a new TransactionOutput with the given address and ADA amount.

Parameters:
  • address (Address) – The recipient address.

  • amount (int) – The amount in lovelace.

Returns:

A new TransactionOutput instance.

Raises:

CardanoError – If creation fails.

Return type:

TransactionOutput

classmethod from_cbor(reader)[source]

Deserializes a TransactionOutput from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the output data.

Returns:

A new TransactionOutput deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

TransactionOutput

to_cbor(writer)[source]

Serializes the transaction output to CBOR format.

Parameters:

writer (CborWriter) – A CborWriter to write the serialized data to.

Raises:

CardanoError – If serialization fails.

Return type:

None

to_cip116_json(writer)[source]

Serializes this transaction output to CIP-116 JSON format.

CIP-116 defines a standard JSON representation for Cardano transactions.

Parameters:

writer – A JsonWriter to write the serialized data to.

Raises:

CardanoError – If serialization fails.

Return type:

None

Example

>>> from cometa.json import JsonWriter
>>> output = TransactionOutput.new(address, 1000000)
>>> writer = JsonWriter()
>>> output.to_cip116_json(writer)
>>> json_str = writer.encode()
property address: Address

The recipient address for this output.

Returns:

The Address where funds are sent.

property value: Value

The value (ADA and multi-assets) held by this output.

Returns:

The Value contained in the output.

__hash__ = None
property datum: Datum | None

The optional datum associated with this output.

A datum is state data used by Plutus scripts to dictate transaction validity based on script logic.

Returns:

The Datum if present, None otherwise.

property script_ref: Script | None

The optional script reference in this output.

Script references allow transactions to refer to scripts included in other outputs, reducing transaction size by not including the script directly.

Returns:

The Script if present, None otherwise.

__eq__(other)[source]

Checks equality with another TransactionOutput.

Parameters:

other (object)

Return type:

bool