Certificate

class cometa.certificates.certificate.Certificate(cert_or_ptr)[source]

Bases: object

Represents a Cardano certificate.

Certificates are a means to encode various essential operations related to stake delegation and stake pool management. Certificates are embedded in transactions and included in blocks. They’re a vital aspect of Cardano’s proof-of-stake mechanism, ensuring that stakeholders can participate in the protocol and its governance.

The Certificate class can be constructed from any specific certificate type:

Example

>>> stake_reg = StakeRegistrationCert.new(credential)
>>> cert = Certificate(stake_reg)  # Automatic conversion
>>> # Or explicitly:
>>> cert = Certificate.from_cert(stake_reg)
__init__(cert_or_ptr)[source]

Creates a Certificate from a raw pointer or a specific certificate type.

Parameters:

cert_or_ptr – Either a raw FFI pointer or a specific certificate instance (e.g., StakeRegistrationCert, PoolRegistrationCert, etc.)

Raises:
  • CardanoError – If creation fails.

  • TypeError – If the argument is not a valid certificate type.

Return type:

None

__enter__()[source]
Return type:

Certificate

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

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod from_cert(cert)[source]

Creates a Certificate from any specific certificate type.

This is an explicit conversion method. You can also use the constructor directly: Certificate(specific_cert).

Parameters:

cert (CertificateUnion) – A specific certificate instance (e.g., StakeRegistrationCert, PoolRegistrationCert, etc.)

Returns:

A new Certificate wrapping the specific certificate.

Raises:

TypeError – If the argument is not a valid certificate type.

Return type:

Certificate

Example

>>> stake_reg = StakeRegistrationCert.new(credential)
>>> cert = Certificate.from_cert(stake_reg)
classmethod new_auth_committee_hot(cert)[source]

Creates a Certificate from an AuthCommitteeHotCert.

Parameters:

cert (AuthCommitteeHotCert)

Return type:

Certificate

classmethod new_genesis_key_delegation(cert)[source]

Creates a Certificate from a GenesisKeyDelegationCert.

Parameters:

cert (GenesisKeyDelegationCert)

Return type:

Certificate

classmethod new_mir(cert)[source]

Creates a Certificate from a MirCert.

Parameters:

cert (MirCert)

Return type:

Certificate

classmethod new_pool_registration(cert)[source]

Creates a Certificate from a PoolRegistrationCert.

Parameters:

cert (PoolRegistrationCert)

Return type:

Certificate

classmethod new_pool_retirement(cert)[source]

Creates a Certificate from a PoolRetirementCert.

Parameters:

cert (PoolRetirementCert)

Return type:

Certificate

classmethod new_register_drep(cert)[source]

Creates a Certificate from a RegisterDRepCert.

Parameters:

cert (RegisterDRepCert)

Return type:

Certificate

classmethod new_registration(cert)[source]

Creates a Certificate from a RegistrationCert.

Parameters:

cert (RegistrationCert)

Return type:

Certificate

classmethod new_resign_committee_cold(cert)[source]

Creates a Certificate from a ResignCommitteeColdCert.

Parameters:

cert (ResignCommitteeColdCert)

Return type:

Certificate

classmethod new_stake_delegation(cert)[source]

Creates a Certificate from a StakeDelegationCert.

Parameters:

cert (StakeDelegationCert)

Return type:

Certificate

classmethod new_stake_deregistration(cert)[source]

Creates a Certificate from a StakeDeregistrationCert.

Parameters:

cert (StakeDeregistrationCert)

Return type:

Certificate

classmethod new_stake_registration(cert)[source]

Creates a Certificate from a StakeRegistrationCert.

Parameters:

cert (StakeRegistrationCert)

Return type:

Certificate

classmethod new_stake_registration_delegation(cert)[source]

Creates a Certificate from a StakeRegistrationDelegationCert.

Parameters:

cert (StakeRegistrationDelegationCert)

Return type:

Certificate

classmethod new_stake_vote_delegation(cert)[source]

Creates a Certificate from a StakeVoteDelegationCert.

Parameters:

cert (StakeVoteDelegationCert)

Return type:

Certificate

classmethod new_stake_vote_registration_delegation(cert)[source]

Creates a Certificate from a StakeVoteRegistrationDelegationCert.

Parameters:

cert (StakeVoteRegistrationDelegationCert)

Return type:

Certificate

classmethod new_unregister_drep(cert)[source]

Creates a Certificate from an UnregisterDRepCert.

Parameters:

cert (UnregisterDRepCert)

Return type:

Certificate

classmethod new_unregistration(cert)[source]

Creates a Certificate from an UnregistrationCert.

Parameters:

cert (UnregistrationCert)

Return type:

Certificate

classmethod new_update_drep(cert)[source]

Creates a Certificate from an UpdateDRepCert.

Parameters:

cert (UpdateDRepCert)

Return type:

Certificate

classmethod new_vote_delegation(cert)[source]

Creates a Certificate from a VoteDelegationCert.

Parameters:

cert (VoteDelegationCert)

Return type:

Certificate

classmethod new_vote_registration_delegation(cert)[source]

Creates a Certificate from a VoteRegistrationDelegationCert.

Parameters:

cert (VoteRegistrationDelegationCert)

Return type:

Certificate

classmethod from_cbor(reader)[source]

Deserializes a Certificate from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the certificate data.

Returns:

A new Certificate deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

Certificate

to_cbor(writer)[source]

Serializes the certificate to CBOR format.

Parameters:

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

Raises:

CardanoError – If serialization fails.

Return type:

None

property cert_type: CertificateType

The type of this certificate.

Returns:

The CertificateType indicating the specific certificate type.

to_auth_committee_hot()[source]

Extracts the underlying AuthCommitteeHotCert.

Return type:

AuthCommitteeHotCert

to_genesis_key_delegation()[source]

Extracts the underlying GenesisKeyDelegationCert.

Return type:

GenesisKeyDelegationCert

to_mir()[source]

Extracts the underlying MirCert.

Return type:

MirCert

to_pool_registration()[source]

Extracts the underlying PoolRegistrationCert.

Return type:

PoolRegistrationCert

to_pool_retirement()[source]

Extracts the underlying PoolRetirementCert.

Return type:

PoolRetirementCert

to_register_drep()[source]

Extracts the underlying RegisterDRepCert.

Return type:

RegisterDRepCert

to_registration()[source]

Extracts the underlying RegistrationCert.

Return type:

RegistrationCert

to_resign_committee_cold()[source]

Extracts the underlying ResignCommitteeColdCert.

Return type:

ResignCommitteeColdCert

to_stake_delegation()[source]

Extracts the underlying StakeDelegationCert.

Return type:

StakeDelegationCert

to_stake_deregistration()[source]

Extracts the underlying StakeDeregistrationCert.

Return type:

StakeDeregistrationCert

to_stake_registration()[source]

Extracts the underlying StakeRegistrationCert.

Return type:

StakeRegistrationCert

to_stake_registration_delegation()[source]

Extracts the underlying StakeRegistrationDelegationCert.

Return type:

StakeRegistrationDelegationCert

to_stake_vote_delegation()[source]

Extracts the underlying StakeVoteDelegationCert.

Return type:

StakeVoteDelegationCert

to_stake_vote_registration_delegation()[source]

Extracts the underlying StakeVoteRegistrationDelegationCert.

Return type:

StakeVoteRegistrationDelegationCert

to_unregister_drep()[source]

Extracts the underlying UnregisterDRepCert.

Return type:

UnregisterDRepCert

to_unregistration()[source]

Extracts the underlying UnregistrationCert.

Return type:

UnregistrationCert

to_update_drep()[source]

Extracts the underlying UpdateDRepCert.

Return type:

UpdateDRepCert

to_vote_delegation()[source]

Extracts the underlying VoteDelegationCert.

Return type:

VoteDelegationCert

to_vote_registration_delegation()[source]

Extracts the underlying VoteRegistrationDelegationCert.

Return type:

VoteRegistrationDelegationCert

to_cip116_json(writer)[source]

Serializes this certificate to CIP-116 compliant JSON.

Parameters:

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

Raises:

CardanoError – If serialization fails.

Return type:

None