Pool parameters

Pool parameters for stake pool registration certificate.

class pycardano.pool_params.PoolId(value: 'str')

Bases: CBORSerializable

value: str
to_primitive() str

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: str) PoolId

Turn a CBOR primitive to its original class type.

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

  • value (Primitive) – A CBOR primitive.

  • type_args (Optional[tuple]) – Type arguments for the class.

Returns:

A CBOR serializable object.

Return type:

CBORBase

Raises:

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

class pycardano.pool_params.PoolMetadata(url: 'str', pool_metadata_hash: 'PoolMetadataHash')

Bases: ArrayCBORSerializable

url: str
pool_metadata_hash: PoolMetadataHash
class pycardano.pool_params.PoolOperator(pool_key_hash: 'PoolKeyHash')

Bases: CBORSerializable

pool_key_hash: PoolKeyHash
encode() str

Encode the pool key hash in Bech32 format.

More info about Bech32 here.

Returns:

Encoded pool key hash in Bech32.

Return type:

str

Examples

>>> pool_key_hash = PoolKeyHash(bytes.fromhex("cc30497f4ff962f4c1dca54cceefe39f86f1d7179668009f8eb71e59"))
>>> pool_operator = PoolOperator(pool_key_hash=pool_key_hash)
>>> print(pool_operator.encode())
pool1escyjl60l930fswu54xvamlrn7r0r4chje5qp8uwku09j7x68x6
classmethod decode(data: str) PoolOperator

Decode a bech32 string into a pool operator object.

Parameters:

data (str) – Bech32-encoded string.

Returns:

Decoded pool operator.

Return type:

PoolOperator

Raises:

DecodingException – When the input string is not a valid Shelley address.

Examples

>>> pool_operator = PoolOperator.decode("pool1escyjl60l930fswu54xvamlrn7r0r4chje5qp8uwku09j7x68x6")
>>> pool_key_hash = PoolKeyHash(bytes.fromhex("cc30497f4ff962f4c1dca54cceefe39f86f1d7179668009f8eb71e59"))
>>> assert pool_operator == PoolOperator(pool_key_hash)
to_shallow_primitive() bytes

Convert the instance to a CBOR primitive. If the primitive is a container, e.g. list, dict, the type of its elements could be either a Primitive or a CBORSerializable.

Returns:

A CBOR primitive.

Return type:

Primitive

Raises:

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

classmethod from_primitive(value: bytes | str) PoolOperator

Turn a CBOR primitive to its original class type.

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

  • value (Primitive) – A CBOR primitive.

  • type_args (Optional[tuple]) – Type arguments for the class.

Returns:

A CBOR serializable object.

Return type:

CBORBase

Raises:

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

class pycardano.pool_params.PoolParams(operator: 'PoolKeyHash', vrf_keyhash: 'VrfKeyHash', pledge: 'int', cost: 'int', margin: 'Fraction', reward_account: 'RewardAccountHash', pool_owners: 'Union[List[VerificationKeyHash], OrderedSet[VerificationKeyHash]]', relays: 'Optional[List[Relay]]' = None, pool_metadata: 'Optional[PoolMetadata]' = None, id: 'Optional[PoolId]' = None)

Bases: ArrayCBORSerializable

operator: PoolKeyHash
vrf_keyhash: VrfKeyHash
pledge: int
cost: int
margin: Fraction
reward_account: RewardAccountHash
pool_owners: List[VerificationKeyHash] | OrderedSet[VerificationKeyHash]
relays: List[SingleHostAddr | SingleHostName | MultiHostName] | None = None
pool_metadata: PoolMetadata | None = None
id: PoolId | None = None
class pycardano.pool_params.SingleHostAddr(port: 'Optional[int]' = None, ipv4: 'Optional[Union[str, bytes]]' = None, ipv6: 'Optional[Union[str, bytes]]' = None)

Bases: ArrayCBORSerializable

port: int | None
ipv4: str | bytes | None
ipv6: str | bytes | None
static ipv4_to_bytes(ip_address: str | bytes | None = None) bytes | None

Convert IPv4 address to bytes format. :param ip_address: The IPv4 address in human-readable format.

Returns:

IPv4 address in bytes format.

Return type:

bytes

static ipv6_to_bytes(ip_address: str | bytes | None = None) bytes | None

Convert IPv6 address to bytes format. :param ip_address: The IPv6 address in human-readable format.

Returns:

The IPv6 address in bytes format.

static bytes_to_ipv4(bytes_ip_address: str | bytes | None = None) str | None

Convert IPv4 address in bytes to human-readable format. :param bytes_ip_address: The IPv4 address in bytes format.

Returns:

The IPv4 address in human-readable format.

static bytes_to_ipv6(bytes_ip_address: str | bytes | None = None) str | None

Convert IPv6 address in bytes to human-readable format. :param bytes_ip_address: The IPv6 address in bytes format.

Returns:

The IPv6 address in human-readable format.

to_primitive() list

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(values: list | tuple) SingleHostAddr

Restore a primitive value to its original class type.

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

  • values (List[Primitive]) – A list whose elements are CBOR primitives.

Returns:

Restored object.

Return type:

ArrayBase

Raises:

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

class pycardano.pool_params.SingleHostName(port: 'Optional[int]', dns_name: 'Optional[str]')

Bases: ArrayCBORSerializable

port: int | None
dns_name: str | None
classmethod from_primitive(values: list | tuple) SingleHostName

Restore a primitive value to its original class type.

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

  • values (List[Primitive]) – A list whose elements are CBOR primitives.

Returns:

Restored object.

Return type:

ArrayBase

Raises:

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

class pycardano.pool_params.MultiHostName(dns_name: 'Optional[str]')

Bases: ArrayCBORSerializable

dns_name: str | None
classmethod from_primitive(values: list | tuple) MultiHostName

Restore a primitive value to its original class type.

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

  • values (List[Primitive]) – A list whose elements are CBOR primitives.

Returns:

Restored object.

Return type:

ArrayBase

Raises:

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

pycardano.pool_params.is_bech32_cardano_pool_id(pool_id: str) bool

Check if a string is a valid Cardano stake pool ID in bech32 format.