RedeemerList

class cometa.witness_set.redeemer_list.RedeemerList(ptr=None)[source]

Bases: Sequence[Redeemer]

Represents a list of redeemers.

This collection type is used in transaction witness sets to hold all redeemers required for script validation.

__init__(ptr=None)[source]
Return type:

None

__enter__()[source]
Return type:

RedeemerList

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

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod from_cbor(reader)[source]

Deserializes a RedeemerList from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the redeemer list data.

Returns:

A new RedeemerList deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

RedeemerList

classmethod from_list(redeemers)[source]

Creates a RedeemerList from an iterable of Redeemer objects.

Parameters:

redeemers (Iterable[Redeemer]) – An iterable of Redeemer objects.

Returns:

A new RedeemerList containing all the redeemers.

Raises:

CardanoError – If creation fails.

Return type:

RedeemerList

to_cbor(writer)[source]

Serializes the redeemer list to CBOR format.

Parameters:

writer (CborWriter) – A CborWriter to write the serialized data to.

Raises:

CardanoError – If serialization fails.

Return type:

None

add(redeemer)[source]

Adds a redeemer to the list.

Parameters:

redeemer (Redeemer) – The Redeemer to add.

Raises:

CardanoError – If addition fails.

Return type:

None

get(index)[source]

Retrieves a redeemer at the specified index.

Parameters:

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

Returns:

The Redeemer at the specified index.

Raises:
  • CardanoError – If retrieval fails.

  • IndexError – If index is out of bounds.

Return type:

Redeemer

set_ex_units(tag, index, mem, steps)[source]

Sets the execution units for a specific redeemer.

Parameters:
  • tag (RedeemerTag) – The redeemer tag type.

  • index (int) – The index of the redeemer.

  • mem (int) – The memory units.

  • steps (int) – The step units.

Raises:

CardanoError – If setting fails.

Return type:

None

clone()[source]

Creates a deep copy of this redeemer list.

Returns:

A new RedeemerList that is a deep copy.

Raises:

CardanoError – If cloning fails.

Return type:

RedeemerList

clear_cbor_cache()[source]

Clears the cached CBOR representation.

This is useful when you have modified the list after it was created from CBOR and you want to ensure that the next serialization reflects the current state rather than using the original cached CBOR.

Warning

Clearing the CBOR cache may change the binary representation when serialized, which can invalidate existing signatures.

Return type:

None

__len__()[source]

Returns the number of redeemers in the list.

Return type:

int

__iter__()[source]

Iterates over all redeemers in the list.

Return type:

Iterator[Redeemer]

__getitem__(index)[source]

Gets a redeemer by index using bracket notation.

Parameters:

index (int)

Return type:

Redeemer

__bool__()[source]

Returns True if the list is not empty.

Return type:

bool

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

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

Returns the index of the first occurrence of value.

Parameters:
  • value (Redeemer) – 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 (Redeemer) – The value to count.

Returns:

The number of occurrences.

Return type:

int