PlutusV2Script
- class cometa.scripts.plutus_scripts.plutus_v2_script.PlutusV2Script(ptr)[source]
Bases:
objectRepresents a Plutus V2 script.
Plutus scripts are pieces of code that implement pure functions with True or False outputs. These functions take several inputs such as Datum, Redeemer and the transaction context to decide whether an output can be spent or not.
V2 was introduced in the Vasil hard fork. The main changes were to the ScriptContext which was extended to include: - The full “redeemers” structure - Reference inputs (CIP-31) - Inline datums (CIP-32) - Reference scripts (CIP-33)
- classmethod new(script_bytes)[source]
Creates a new PlutusV2Script from raw bytes.
- Parameters:
script_bytes (bytes) – The compiled Plutus script bytes.
- Returns:
A new PlutusV2Script instance.
- Raises:
CardanoError – If creation fails.
- Return type:
- classmethod from_hex(hex_string)[source]
Creates a new PlutusV2Script from a hexadecimal string.
- Parameters:
hex_string (str) – The compiled Plutus script as a hex string.
- Returns:
A new PlutusV2Script instance.
- Raises:
CardanoError – If creation fails.
- Return type:
- classmethod from_cbor(reader)[source]
Deserializes a PlutusV2Script from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the script data.
- Returns:
A new PlutusV2Script 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
- property hash: bytes
The hash of this script.
- Returns:
The 28-byte Blake2b hash of the script.
- property raw_bytes: bytes
The raw bytes of the compiled script.
- Returns:
The raw script bytes.
- __eq__(other)[source]
Checks equality with another PlutusV2Script.
- Parameters:
other (object)
- Return type:
bool
- __hash__ = None