TransactionOutput
- class cometa.transaction_body.transaction_output.TransactionOutput(ptr)[source]
Bases:
objectRepresents 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
- 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:
- 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:
- 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.