DRep
- class cometa.common.drep.DRep(ptr)[source]
Bases:
objectRepresents a Delegated Representative (DRep) for governance participation.
In Voltaire, stake credentials can delegate their voting power to DReps for governance decisions. DReps can be identified by:
A verification key (Ed25519) - KEY_HASH type
A native or Plutus script - SCRIPT_HASH type
Additionally, two pre-defined options are available: - ABSTAIN: Actively marks stake as not participating in governance - NO_CONFIDENCE: Votes “Yes” on No Confidence actions, “No” on all others
Example
>>> cred = Credential.from_key_hash("00" * 28) >>> drep = DRep.new(DRepType.KEY_HASH, cred)
- classmethod new(drep_type, credential=None)[source]
Creates a new DRep with the specified type and optional credential.
- Parameters:
drep_type (DRepType) – The type of DRep (KEY_HASH, SCRIPT_HASH, ABSTAIN, or NO_CONFIDENCE).
credential (Credential | None) – The credential for KEY_HASH or SCRIPT_HASH types. Must be None for ABSTAIN and NO_CONFIDENCE types.
- Returns:
A new DRep instance.
- Raises:
CardanoError – If creation fails.
- Return type:
Example
>>> cred = Credential.from_key_hash("00" * 28) >>> drep = DRep.new(DRepType.KEY_HASH, cred) >>> abstain = DRep.new(DRepType.ABSTAIN)
- classmethod from_string(bech32_string)[source]
Creates a DRep from a Bech32-encoded string (CIP-105 or CIP-129 format).
Supports both: - CIP-105 format: Key hash directly as Bech32 - CIP-129 format: Includes header byte with governance key type and credential type
- Parameters:
bech32_string (str) – The Bech32-encoded DRep string.
- Returns:
A new DRep instance.
- Raises:
CardanoError – If parsing fails.
- Return type:
Example
>>> drep = DRep.from_string("drep1...")
- classmethod from_cbor(reader)[source]
Deserializes a DRep from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the DRep data.
- Returns:
A new DRep deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- classmethod abstain()[source]
Creates a DRep representing the Abstain voting option.
- Returns:
A new DRep with type ABSTAIN.
- Return type:
- classmethod no_confidence()[source]
Creates a DRep representing the No Confidence voting option.
- Returns:
A new DRep with type NO_CONFIDENCE.
- Return type:
- property credential: Credential | None
Returns the credential associated with this DRep.
Returns None for ABSTAIN and NO_CONFIDENCE types.
- to_cbor(writer)[source]
Serializes the DRep to CBOR format.
- Parameters:
writer (CborWriter) – A CborWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- to_cip116_json(writer)[source]
Converts this object to CIP-116 compliant JSON representation.
CIP-116 defines a standard JSON format for Cardano data structures.
- Parameters:
writer (JsonWriter) – A JsonWriter to write the serialized data to.
- Raises:
CardanoError – If conversion fails.
- Return type:
None