MetadatumLabelList

class cometa.auxiliary_data.metadatum_label_list.MetadatumLabelList(ptr=None)[source]

Bases: Sequence[int]

Represents a list of metadatum labels (unsigned 64-bit integers).

Labels are used to identify metadata entries in transactions. Common labels include 721 for NFTs (CIP-25).

Example

>>> label_list = MetadatumLabelList()
>>> label_list.add(721)
>>> label_list.add(674)
>>> len(label_list)
2
__init__(ptr=None)[source]
Return type:

None

classmethod from_list(labels)[source]

Creates a MetadatumLabelList from an iterable of integers.

Parameters:

labels (Iterable[int]) – An iterable of metadata labels (unsigned 64-bit integers).

Returns:

A new MetadatumLabelList containing all the labels.

Raises:

CardanoError – If creation fails.

Return type:

MetadatumLabelList

__enter__()[source]
Return type:

MetadatumLabelList

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

None

__repr__()[source]

Return repr(self).

Return type:

str

add(label)[source]

Adds a label to the list.

Parameters:

label (int) – The metadata label (unsigned 64-bit integer).

Raises:

CardanoError – If the operation fails.

Return type:

None

get(index)[source]

Retrieves a label by index.

Parameters:

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

Returns:

The label at the specified index.

Raises:
  • CardanoError – If retrieval fails.

  • IndexError – If index is out of bounds.

Return type:

int

__len__()[source]

Returns the number of elements in the list.

Return type:

int

__iter__()[source]

Iterates over all labels in the list.

Return type:

Iterator[int]

__getitem__(index)[source]

Gets a label by index using bracket notation. Supports negative indices.

Parameters:

index (int)

Return type:

int

__contains__(item)[source]

Checks if a label is in the list.

Parameters:

item (int)

Return type:

bool

__bool__()[source]

Returns True if the list is not empty.

Return type:

bool

append(label)[source]

Appends a label to the list.

This is an alias for add() to match Python list semantics.

Parameters:

label (int) – The metadata label to append.

Return type:

None

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

Returns the index of the first occurrence of value.

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

Returns:

The number of occurrences.

Return type:

int