Certificate
- class pycardano.certificate.StakeCredential(credential: VerificationKeyHash | ScriptHash)
Bases:
ArrayCBORSerializableRepresents a stake credential in the Cardano blockchain.
A stake credential can either be a verification key hash or a script hash, used to identify stake rights and permissions.
- credential: VerificationKeyHash | ScriptHash
The actual credential, either a verification key hash or script hash
- classmethod from_primitive(values: list | tuple) StakeCredential
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.certificate.StakeRegistration(stake_credential: StakeCredential)
Bases:
CodedSerializableCertificate for registering a stake credential.
- stake_credential: StakeCredential
The stake credential being registered
- class pycardano.certificate.StakeDeregistration(stake_credential: StakeCredential)
Bases:
CodedSerializableCertificate for deregistering a stake credential.
- stake_credential: StakeCredential
The stake credential being deregistered
- class pycardano.certificate.StakeDelegation(stake_credential: StakeCredential, pool_keyhash: PoolKeyHash)
Bases:
CodedSerializableCertificate for delegating stake to a stake pool.
- stake_credential: StakeCredential
The stake credential being delegated
- pool_keyhash: PoolKeyHash
The hash of the pool’s key to delegate to
- class pycardano.certificate.PoolRegistration(pool_params: PoolParams)
Bases:
CodedSerializableCertificate for registering a stake pool.
- pool_params: PoolParams
The parameters defining the stake pool’s configuration
- to_primitive()
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) PoolRegistration
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.certificate.PoolRetirement(pool_keyhash: PoolKeyHash, epoch: int)
Bases:
CodedSerializableCertificate for retiring a stake pool.
- pool_keyhash: PoolKeyHash
The hash of the pool’s key that is being retired
- epoch: int
The epoch number when the pool will retire
- class pycardano.certificate.StakeRegistrationConway(stake_credential: StakeCredential, coin: int)
Bases:
CodedSerializableCertificate for registering a stake credential in the Conway era.
- stake_credential: StakeCredential
The stake credential being registered
- coin: int
The amount of coins associated with this registration
- class pycardano.certificate.StakeDeregistrationConway(stake_credential: StakeCredential, coin: int)
Bases:
CodedSerializableCertificate for deregistering a stake credential in the Conway era.
- stake_credential: StakeCredential
The stake credential being deregistered
- coin: int
The amount of coins associated with this deregistration
- class pycardano.certificate.VoteDelegation(stake_credential: StakeCredential, drep: DRep)
Bases:
CodedSerializableCertificate for delegating voting power to a DRep.
- stake_credential: StakeCredential
The stake credential delegating its voting power
- class pycardano.certificate.StakeAndVoteDelegation(stake_credential: StakeCredential, pool_keyhash: PoolKeyHash, drep: DRep)
Bases:
CodedSerializableCertificate for delegating both stake and voting power.
- stake_credential: StakeCredential
The stake credential being delegated
- pool_keyhash: PoolKeyHash
The hash of the pool’s key receiving the stake delegation
- class pycardano.certificate.StakeRegistrationAndDelegation(stake_credential: StakeCredential, pool_keyhash: PoolKeyHash, coin: int)
Bases:
CodedSerializableCertificate for registering stake and delegating to a pool.
- stake_credential: StakeCredential
The stake credential being registered and delegated
- pool_keyhash: PoolKeyHash
The hash of the pool’s key receiving the delegation
- coin: int
The amount of coins associated with this registration
- class pycardano.certificate.StakeRegistrationAndVoteDelegation(stake_credential: StakeCredential, drep: DRep, coin: int)
Bases:
CodedSerializableCertificate for registering stake and delegating voting power.
- stake_credential: StakeCredential
The stake credential being registered
- coin: int
The amount of coins associated with this registration
- class pycardano.certificate.StakeRegistrationAndDelegationAndVoteDelegation(stake_credential: StakeCredential, pool_keyhash: PoolKeyHash, drep: DRep, coin: int)
Bases:
CodedSerializableCertificate for registering stake and delegating both stake and voting power.
- stake_credential: StakeCredential
The stake credential being registered and delegated
- pool_keyhash: PoolKeyHash
The hash of the pool’s key receiving the stake delegation
- coin: int
The amount of coins associated with this registration
- class pycardano.certificate.DRep(kind: DRepKind, credential: VerificationKeyHash | ScriptHash | None = None, id_format: IdFormat = IdFormat.CIP129)
Bases:
ArrayCBORSerializableRepresents a Delegate Representative (DRep) in the Cardano governance system.
DReps are entities that can represent stake holders in governance decisions.
- kind: DRepKind
The type of DRep (verification key, script hash, always abstain, or always no confidence)
- credential: VerificationKeyHash | ScriptHash | None = None
The credential associated with this DRep, if applicable
- id_format: IdFormat = 'cip129'
- classmethod from_primitive(values: list | tuple) DRep
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.
- to_primitive()
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.
- encode() str
Encode the DRep in Bech32 format.
More info about Bech32 here.
- Returns:
Encoded DRep in Bech32 format.
- Return type:
str
Examples
>>> vkey_bytes = bytes.fromhex("00000000000000000000000000000000000000000000000000000000") >>> credential = VerificationKeyHash(vkey_bytes) >>> print(DRep(kind=DRepKind.VERIFICATION_KEY_HASH, credential=credential).encode()) drep1ygqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq7vlc9n
- classmethod decode(data: str) DRep
Decode a bech32 string into a DRep object.
- Parameters:
data (str) – Bech32-encoded string.
- Returns:
Decoded DRep.
- Return type:
- Raises:
DecodingException – When the input string is not a valid DRep.
Examples
>>> credential = DRep.decode("drep1ygqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq7vlc9n") >>> khash = VerificationKeyHash(bytes.fromhex("00000000000000000000000000000000000000000000000000000000")) >>> assert credential == DRep(DRepKind.VERIFICATION_KEY_HASH, khash)
- class pycardano.certificate.DRepKind(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
EnumEnumerates the different types of Delegate Representatives (DReps).
Defines the possible kinds of DReps in the Cardano governance system: - VERIFICATION_KEY_HASH: A DRep identified by a verification key hash - SCRIPT_HASH: A DRep identified by a script hash - ALWAYS_ABSTAIN: A special DRep that always abstains from voting - ALWAYS_NO_CONFIDENCE: A special DRep that always votes no confidence
- VERIFICATION_KEY_HASH = 0
- SCRIPT_HASH = 1
- ALWAYS_ABSTAIN = 2
- ALWAYS_NO_CONFIDENCE = 3
- class pycardano.certificate.AuthCommitteeHotCertificate(committee_cold_credential: StakeCredential, committee_hot_credential: StakeCredential)
Bases:
CodedSerializableCertificate for authorizing a committee hot key.
- committee_cold_credential: StakeCredential
The cold credential of the committee member
- committee_hot_credential: StakeCredential
The hot credential being authorized
- class pycardano.certificate.ResignCommitteeColdCertificate(committee_cold_credential: StakeCredential, anchor: Anchor | None)
Bases:
CodedSerializableCertificate for resigning from the constitutional committee.
- committee_cold_credential: StakeCredential
The cold credential of the resigning committee member
- class pycardano.certificate.Anchor(url: str, data_hash: AnchorDataHash)
Bases:
ArrayCBORSerializableRepresents an anchor in the Cardano blockchain that contains a URL and associated data hash.
Anchors are used to provide additional metadata or reference external resources in certificates.
- url: str
The URL pointing to the anchor’s resource location
- data_hash: AnchorDataHash
The hash of the data associated with this anchor
- class pycardano.certificate.DRepCredential(credential: VerificationKeyHash | ScriptHash, governance_key_type: GovernanceKeyType = GovernanceKeyType.DREP, id_format: IdFormat = IdFormat.CIP129)
Bases:
GovernanceCredentialRepresents a Delegate Representative (DRep) credential.
This credential type is specifically used for DReps in the governance system, inheriting from GovernanceCredential.
- governance_key_type: GovernanceKeyType = 2
Governance key type.
- class pycardano.certificate.RegDRepCert(drep_credential: DRepCredential, coin: int, anchor: Anchor | None = None)
Bases:
CodedSerializableCertificate for registering as a delegate representative (DRep).
- drep_credential: DRepCredential
The credential of the DRep being registered
- coin: int
The amount of coins associated with this registration
- class pycardano.certificate.UnregDRepCertificate(drep_credential: DRepCredential, coin: int)
Bases:
CodedSerializableCertificate for unregistering as a delegate representative (DRep).
- drep_credential: DRepCredential
The credential of the DRep being unregistered
- coin: int
The amount of coins associated with this unregistration
- class pycardano.certificate.UpdateDRepCertificate(drep_credential: DRepCredential, anchor: Anchor | None)
Bases:
CodedSerializableCertificate for updating delegate representative (DRep) metadata.
- drep_credential: DRepCredential
The credential of the DRep being updated
- class pycardano.certificate.GovernanceCredential(credential: VerificationKeyHash | ScriptHash, id_format: IdFormat = IdFormat.CIP129)
Bases:
StakeCredentialRepresents a governance credential.
- governance_key_type: GovernanceKeyType
Governance key type.
- id_format: IdFormat = 'cip129'
Id format.
- property credential_type: CredentialType
Credential type.
- encode() str
Encode the governance credential in Bech32 format.
More info about Bech32 here.
- Returns:
Encoded governance credential in Bech32 format.
- Return type:
str
- classmethod decode(data: str) GovernanceCredential
Decode a bech32 string into a governance credential object.
- Parameters:
data (str) – Bech32-encoded string.
- Returns:
Decoded governance credential.
- Return type:
- Raises:
DecodingException – When the input string is not a valid governance credential.
- to_primitive()
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.