Metadata

class pycardano.metadata.Metadata(*args, **kwargs)

Bases: DictCBORSerializable

KEY_TYPE

alias of int

VALUE_TYPE = typing.Any
MAX_ITEM_SIZE = 64
INTERNAL_TYPES = (<class 'dict'>, <class 'list'>, <class 'int'>, <class 'bytes'>, <class 'str'>)
class pycardano.metadata.ShelleyMarryMetadata(metadata: 'Metadata', native_scripts: 'Optional[List[NativeScript]]' = None)

Bases: ArrayCBORSerializable

metadata: Metadata
native_scripts: Optional[List[NativeScript]] = None
class pycardano.metadata.AlonzoMetadata(metadata: 'Optional[Metadata]' = None, native_scripts: 'Optional[List[NativeScript]]' = None, plutus_v1_scripts: 'Optional[List[PlutusV1Script]]' = None, plutus_v2_scripts: 'Optional[List[PlutusV2Script]]' = None, plutus_v3_scripts: 'Optional[List[PlutusV3Script]]' = None)

Bases: MapCBORSerializable

TAG: ClassVar[int] = 259
metadata: Optional[Metadata] = None
native_scripts: Optional[List[NativeScript]] = None
plutus_v1_scripts: Optional[List[PlutusV1Script]] = None
plutus_v2_scripts: Optional[List[PlutusV2Script]] = None
plutus_v3_scripts: Optional[List[PlutusV3Script]] = None
to_primitive() Union[bytes, bytearray, str, int, float, Decimal, bool, None, tuple, list, IndefiniteList, dict, defaultdict, OrderedDict, datetime, Pattern, CBORSimpleValue, CBORTag, set, frozenset, frozendict, FrozenList, IndefiniteFrozenList, ByteString]

Convert the instance and its elements to CBOR primitives recursively.

Returns:

A CBOR primitive.

Return type:

Primitive

Raises:

SerializeException – When the object or its elements could not be converted to CBOR primitive types.

classmethod from_primitive(value: CBORTag) AlonzoMetadata

Restore a primitive value to its original class type.

Parameters:
  • cls (MapBase) – The original class type.

  • values (Primitive) – A CBOR primitive.

Returns:

Restored object.

Return type:

MapBase

Raises:

pycardano.exception.DeserializeException – When the object could not be restored from primitives.

class pycardano.metadata.AuxiliaryData(data: 'Union[Metadata, ShelleyMarryMetadata, AlonzoMetadata]')

Bases: CBORSerializable

data: Union[Metadata, ShelleyMarryMetadata, AlonzoMetadata]
to_primitive() Union[bytes, bytearray, str, int, float, Decimal, bool, None, tuple, list, IndefiniteList, dict, defaultdict, OrderedDict, datetime, Pattern, CBORSimpleValue, CBORTag, set, frozenset, frozendict, FrozenList, IndefiniteFrozenList, ByteString]

Convert the instance and its elements to CBOR primitives recursively.

Returns:

A CBOR primitive.

Return type:

Primitive

Raises:

SerializeException – When the object or its elements could not be converted to CBOR primitive types.

classmethod from_primitive(value: Union[bytes, bytearray, str, int, float, Decimal, bool, None, tuple, list, IndefiniteList, dict, defaultdict, OrderedDict, datetime, Pattern, CBORSimpleValue, CBORTag, set, frozenset, frozendict, FrozenList, IndefiniteFrozenList, ByteString]) AuxiliaryData

Turn a CBOR primitive to its original class type.

Parameters:
  • cls (CBORBase) – The original class type.

  • value (Primitive) – A CBOR primitive.

Returns:

A CBOR serializable object.

Return type:

CBORBase

Raises:

DeserializeException – When the object could not be restored from primitives.

hash() AuxiliaryDataHash