ScriptNOfK
- class cometa.scripts.native_scripts.script_n_of_k.ScriptNOfK(ptr)[source]
Bases:
objectRepresents an N-of-K script that requires N sub-scripts to evaluate to true.
This script evaluates to true if at least N (required) of the sub-scripts evaluate to true. If N is greater than the number of sub-scripts, this script evaluates to false.
- classmethod new(scripts, required)[source]
Creates a new ScriptNOfK with the given sub-scripts and required count.
- Parameters:
scripts (NativeScriptList | List[Any]) – The list of native scripts. Can be a NativeScriptList or a Python list of native scripts.
required (int) – The number of sub-scripts that must evaluate to true.
- Returns:
A new ScriptNOfK instance.
- Raises:
CardanoError – If creation fails.
- Return type:
- classmethod from_cbor(reader)[source]
Deserializes a ScriptNOfK from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the script data.
- Returns:
A new ScriptNOfK deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- to_cbor(writer)[source]
Serializes the script 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 object to CIP-116 compliant JSON.
- Parameters:
writer (JsonWriter) – The JsonWriter to write the JSON to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- property required: int
The number of sub-scripts required to evaluate to true.
- Returns:
The required count.
- property scripts: NativeScriptList
The list of sub-scripts.
- Returns:
The NativeScriptList containing all sub-scripts.
- property hash: bytes
The hash of this native script.
- Returns:
The 28-byte Blake2b hash.
- __hash__ = None