PlutusDataSet
- class cometa.witness_set.plutus_data_set.PlutusDataSet(ptr=None)[source]
Bases:
Set[PlutusData]Represents a set of Plutus data.
Plutus data is used in Plutus scripts to carry additional information during script execution. The datum is a piece of data attached to UTXOs that scripts can use to validate transactions.
- classmethod from_cbor(reader)[source]
Deserializes a PlutusDataSet from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the data set.
- Returns:
A new PlutusDataSet deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- classmethod from_list(data_items)[source]
Creates a PlutusDataSet from an iterable of PlutusData objects.
- Parameters:
data_items (Iterable[PlutusData]) – An iterable of PlutusData objects.
- Returns:
A new PlutusDataSet containing all the data items.
- Raises:
CardanoError – If creation fails.
- Return type:
- to_cbor(writer)[source]
Serializes the data set to CBOR format.
- Parameters:
writer (CborWriter) – A CborWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- add(data)[source]
Adds Plutus data to the set.
- Parameters:
data (PlutusData) – The PlutusData to add.
- Raises:
CardanoError – If addition fails.
- Return type:
None
- get(index)[source]
Retrieves Plutus data at the specified index.
- Parameters:
index (int) – The index of the data to retrieve.
- Returns:
The PlutusData at the specified index.
- Raises:
CardanoError – If retrieval fails.
IndexError – If index is out of bounds.
- Return type:
- property use_tag: bool
Whether the set uses Conway era tagged encoding.
- Returns:
True if using tagged encoding, False for legacy array encoding.
- clear_cbor_cache()[source]
Clears the cached CBOR representation.
This is useful when you have modified the set after it was created from CBOR and you want to ensure that the next serialization reflects the current state rather than using the original cached CBOR.
Warning
Clearing the CBOR cache may change the binary representation when serialized, which can invalidate existing signatures.
- Return type:
None
- __iter__()[source]
Iterates over all data items in the set.
- Return type:
Iterator[PlutusData]
- __getitem__(index)[source]
Gets data by index using bracket notation.
- Parameters:
index (int)
- Return type:
- to_cip116_json(writer)[source]
Serializes this object to CIP-116 compliant JSON.
- Parameters:
writer (JsonWriter) – The JsonWriter to write the JSON to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- __contains__(item)[source]
Checks if an item is in the set.
- Parameters:
item (object)
- Return type:
bool
- isdisjoint(other)[source]
Returns True if the set has no elements in common with other.
- Parameters:
other (Iterable[PlutusData]) – Another iterable to compare with.
- Returns:
True if the sets are disjoint.
- Return type:
bool