GovernanceActionId

class cometa.common.governance_action_id.GovernanceActionId(ptr)[source]

Bases: object

Represents a unique identifier for a governance action on the Cardano blockchain.

Each governance action accepted on-chain is assigned a unique identifier consisting of: - The transaction hash of the transaction that created it - The index within the transaction body pointing to the governance action

This identifier is used to reference specific governance actions in voting, ratification, and other governance-related operations.

Example

>>> gov_id = GovernanceActionId.from_hash_hex("00" * 32, 0)
>>> gov_id.index
0
__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

GovernanceActionId

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

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod new(transaction_hash, index)[source]

Creates a new governance action ID from a transaction hash and index.

Parameters:
  • transaction_hash (Blake2bHash) – The Blake2b hash of the transaction containing the action.

  • index (int) – The index within the transaction body pointing to the governance action.

Returns:

A new GovernanceActionId instance.

Raises:

CardanoError – If creation fails.

Return type:

GovernanceActionId

Example

>>> tx_hash = Blake2bHash.from_hex("00" * 32)
>>> gov_id = GovernanceActionId.new(tx_hash, 0)
classmethod from_bech32(bech32_string)[source]

Creates a governance action ID from a Bech32-encoded string (CIP-129 format).

Parameters:

bech32_string (str) – The Bech32-encoded governance action ID string.

Returns:

A new GovernanceActionId instance.

Raises:

CardanoError – If parsing fails.

Return type:

GovernanceActionId

Example

>>> gov_id = GovernanceActionId.from_bech32("gov_action1...")
classmethod from_hash_hex(hex_string, index)[source]

Creates a governance action ID from a hexadecimal transaction hash string.

Parameters:
  • hex_string (str) – The transaction hash as a hexadecimal string.

  • index (int) – The index within the transaction body.

Returns:

A new GovernanceActionId instance.

Raises:

CardanoError – If creation fails or hash is invalid.

Return type:

GovernanceActionId

Example

>>> gov_id = GovernanceActionId.from_hash_hex("abcd1234" * 8, 1)
classmethod from_hash_bytes(data, index)[source]

Creates a governance action ID from raw transaction hash bytes.

Parameters:
  • data (bytes | bytearray) – The transaction hash as raw bytes.

  • index (int) – The index within the transaction body.

Returns:

A new GovernanceActionId instance.

Raises:

CardanoError – If creation fails.

Return type:

GovernanceActionId

Example

>>> gov_id = GovernanceActionId.from_hash_bytes(bytes(32), 0)
classmethod from_cbor(reader)[source]

Deserializes a GovernanceActionId from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the governance action ID data.

Returns:

A new GovernanceActionId deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

GovernanceActionId

property transaction_hash: Blake2bHash

Returns the transaction hash associated with this governance action ID.

property index: int

Returns the index within the transaction body.

property hash_hex: str

Returns the transaction hash as a hexadecimal string.

property hash_bytes: bytes

Returns the transaction hash as raw bytes.

to_bech32()[source]

Returns the CIP-129 Bech32 string representation.

Returns:

The governance action ID as a Bech32-encoded string.

Raises:

CardanoError – If conversion fails.

Return type:

str

to_cbor(writer)[source]

Serializes the governance action ID 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

__eq__(other)[source]

Checks equality with another GovernanceActionId.

Parameters:

other (object)

Return type:

bool

__hash__()[source]

Returns a Python hash for use in sets and dicts.

Return type:

int

__str__()[source]

Returns the Bech32 string representation.

Return type:

str