PlutusV1Script

class cometa.scripts.plutus_scripts.plutus_v1_script.PlutusV1Script(ptr)[source]

Bases: object

Represents a Plutus V1 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.

V1 was the initial version of Plutus, introduced in the Alonzo hard fork.

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

PlutusV1Script

__exit__(exc_type, exc_val, exc_tb)[source]
Return type:

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod new(script_bytes)[source]

Creates a new PlutusV1Script from raw bytes.

Parameters:

script_bytes (bytes) – The compiled Plutus script bytes.

Returns:

A new PlutusV1Script instance.

Raises:

CardanoError – If creation fails.

Return type:

PlutusV1Script

classmethod from_hex(hex_string)[source]

Creates a new PlutusV1Script from a hexadecimal string.

Parameters:

hex_string (str) – The compiled Plutus script as a hex string.

Returns:

A new PlutusV1Script instance.

Raises:

CardanoError – If creation fails.

Return type:

PlutusV1Script

classmethod from_cbor(reader)[source]

Deserializes a PlutusV1Script from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the script data.

Returns:

A new PlutusV1Script deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

PlutusV1Script

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 PlutusV1Script.

Parameters:

other (object)

Return type:

bool

__hash__ = None