PoolMetadata

class cometa.pool_params.pool_metadata.PoolMetadata(ptr)[source]

Bases: object

Represents pool metadata for a Cardano stake pool.

Pool metadata includes a URL pointing to a JSON file containing pool information and a Blake2b-256 hash of that file for integrity verification.

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

PoolMetadata

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

None

__repr__()[source]

Return repr(self).

Return type:

str

__str__()[source]

Return str(self).

Return type:

str

classmethod new(url, metadata_hash)[source]

Creates a new pool metadata object.

Parameters:
  • url (str) – The URL pointing to the pool metadata JSON file.

  • metadata_hash (Blake2bHash) – The Blake2b-256 hash of the metadata file.

Returns:

A new PoolMetadata instance.

Raises:

CardanoError – If creation fails.

Return type:

PoolMetadata

Example

>>> hash = Blake2bHash.from_hex("00" * 32)
>>> metadata = PoolMetadata.new("https://example.com/pool.json", hash)
classmethod from_hash_hex(url, hash_hex)[source]

Creates a new pool metadata object from a URL and hex-encoded hash.

Parameters:
  • url (str) – The URL pointing to the pool metadata JSON file.

  • hash_hex (str) – The Blake2b-256 hash as a hexadecimal string.

Returns:

A new PoolMetadata instance.

Raises:

CardanoError – If creation fails.

Return type:

PoolMetadata

Example

>>> metadata = PoolMetadata.from_hash_hex(
...     "https://example.com/pool.json",
...     "00" * 32
... )
classmethod from_cbor(reader)[source]

Deserializes a PoolMetadata from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the pool metadata data.

Returns:

A new PoolMetadata deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

PoolMetadata

to_cbor(writer)[source]

Serializes the pool metadata to CBOR format.

Parameters:

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

Raises:

CardanoError – If serialization fails.

Return type:

None

property url: str

Returns the metadata URL.

property hash: Blake2bHash

Returns the metadata hash.

to_cip116_json(writer)[source]

Serializes this pool metadata to CIP-116 compliant JSON.

Parameters:

writer (JsonWriter) – The JsonWriter to write the JSON to.

Raises:

CardanoError – If serialization fails.

Return type:

None