PlutusV3ScriptList

class cometa.auxiliary_data.plutus_v3_script_list.PlutusV3ScriptList(ptr=None)[source]

Bases: Sequence[PlutusV3Script]

Represents a list of Plutus V3 scripts.

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.

V3 was introduced in the Conway hard fork.

The main changes in V3 of Plutus were to the interface to scripts. The ScriptContext was extended to include the following information: - A Map with all the votes that were included in the transaction - A list with Proposals that will be turned into GovernanceActions, that everyone can vote on - Optional amount for the current treasury. If included it will be checked to be equal the current amount in the treasury - Optional amount for donating to the current treasury. If included, specified amount will go into the treasury

Example

>>> from cometa import PlutusV3ScriptList
>>> script_list = PlutusV3ScriptList()
>>> script_list.add(script)
>>> print(len(script_list))
1
__init__(ptr=None)[source]
Return type:

None

__enter__()[source]
Return type:

PlutusV3ScriptList

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

None

__repr__()[source]

Return repr(self).

Return type:

str

__len__()[source]

Returns the number of Plutus V3 scripts in the list.

Return type:

int

__iter__()[source]

Iterates over all Plutus V3 scripts in the list.

Return type:

Iterator[PlutusV3Script]

__getitem__(index)[source]

Gets a Plutus V3 script by index using bracket notation.

Parameters:

index (int)

Return type:

PlutusV3Script

__bool__()[source]

Returns True if the list is not empty.

Return type:

bool

classmethod from_list(scripts)[source]

Creates a PlutusV3ScriptList from a Python list of PlutusV3Script objects.

Parameters:

scripts (list[PlutusV3Script]) – A list of PlutusV3Script objects.

Returns:

A new PlutusV3ScriptList containing all the scripts.

Raises:

CardanoError – If creation fails.

Return type:

PlutusV3ScriptList

Example

>>> script_list = PlutusV3ScriptList.from_list([script1, script2, script3])
classmethod from_cbor(cbor_hex)[source]

Creates a PlutusV3ScriptList from a CBOR hex string.

Parameters:

cbor_hex (str) – A hex-encoded CBOR string.

Returns:

A new PlutusV3ScriptList decoded from the CBOR.

Raises:

CardanoError – If decoding fails.

Return type:

PlutusV3ScriptList

Example

>>> script_list = PlutusV3ScriptList.from_cbor("82...")
to_cbor()[source]

Serializes the PlutusV3ScriptList to CBOR format.

Returns:

A hex-encoded CBOR string.

Raises:

CardanoError – If serialization fails.

Return type:

str

Example

>>> cbor_hex = script_list.to_cbor()
add(script)[source]

Adds a Plutus V3 script to the end of the list.

Parameters:

script (PlutusV3Script) – The PlutusV3Script to add.

Raises:

CardanoError – If addition fails.

Return type:

None

get(index)[source]

Retrieves a Plutus V3 script at the specified index.

Parameters:

index (int) – The index of the script to retrieve.

Returns:

The PlutusV3Script at the specified index.

Raises:
  • CardanoError – If retrieval fails.

  • IndexError – If index is out of bounds.

Return type:

PlutusV3Script

append(script)[source]

Appends a Plutus V3 script to the end of the list.

This is an alias for add() to provide a more Pythonic interface.

Parameters:

script (PlutusV3Script) – The PlutusV3Script to append.

Raises:

CardanoError – If addition fails.

Return type:

None

index(value, start=0, stop=None)[source]

Returns the index of the first occurrence of value.

Parameters:
  • value (PlutusV3Script) – The value to search for.

  • start (int) – Start searching from this index.

  • stop (int | None) – Stop searching at this index.

Returns:

The index of the first occurrence.

Raises:

ValueError – If the value is not found.

Return type:

int

count(value)[source]

Returns the number of occurrences of value.

Parameters:

value (PlutusV3Script) – The value to count.

Returns:

The number of occurrences.

Return type:

int