PlutusV2ScriptSet
- class cometa.witness_set.plutus_v2_script_set.PlutusV2ScriptSet(ptr=None)[source]
Bases:
Set[PlutusV2Script]Represents a set of Plutus V2 scripts.
Plutus V2 scripts are smart contracts introduced in the Vasil hard fork. V2 scripts have access to reference inputs, inline datums, and reference scripts, making them more efficient than V1 scripts.
- __init__(ptr=None)[source]
Initializes a new PlutusV2ScriptSet.
- Parameters:
ptr – Optional FFI pointer to an existing script set. If None, creates a new set.
- Raises:
CardanoError – If creation fails or if ptr is NULL.
- Return type:
None
- classmethod from_cbor(reader)[source]
Deserializes a PlutusV2ScriptSet from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the script set data.
- Returns:
A new PlutusV2ScriptSet deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- classmethod from_list(scripts)[source]
Creates a PlutusV2ScriptSet from an iterable of PlutusV2Script objects.
- Parameters:
scripts (Iterable[PlutusV2Script]) – An iterable of PlutusV2Script objects.
- Returns:
A new PlutusV2ScriptSet containing all the scripts.
- Raises:
CardanoError – If creation fails.
- Return type:
- to_cbor(writer)[source]
Serializes the script set to CBOR format.
- Parameters:
writer (CborWriter) – A CborWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- property use_tag: bool
Whether the set uses Conway era tagged encoding.
- Returns:
True if using tagged encoding, False for legacy array encoding.
- add(script)[source]
Adds a Plutus V2 script to the set.
- Parameters:
script (PlutusV2Script) – The PlutusV2Script to add.
- Raises:
CardanoError – If addition fails.
- Return type:
None
- get(index)[source]
Retrieves a Plutus V2 script at the specified index.
- Parameters:
index (int) – The index of the script to retrieve.
- Returns:
The PlutusV2Script at the specified index.
- Raises:
CardanoError – If retrieval fails.
IndexError – If index is out of bounds.
- Return type:
- __iter__()[source]
Iterates over all scripts in the set.
- Return type:
Iterator[PlutusV2Script]
- __getitem__(index)[source]
Gets a script by index using bracket notation.
- Parameters:
index (int)
- Return type:
- __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[PlutusV2Script]) – Another iterable to compare with.
- Returns:
True if the sets are disjoint.
- Return type:
bool