VotingProcedure

class cometa.voting_procedures.voting_procedure.VotingProcedure(ptr)[source]

Bases: object

Represents a voting procedure in the Cardano governance system.

A voting procedure consists of: - A vote (Yes, No, or Abstain) - An optional anchor that links the vote to arbitrary off-chain JSON metadata

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

VotingProcedure

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

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod new(vote, anchor=None)[source]

Creates a new voting procedure.

Parameters:
  • vote (Vote) – The vote choice (YES, NO, or ABSTAIN).

  • anchor (Anchor | None) – Optional anchor linking to off-chain metadata.

Returns:

A new VotingProcedure instance.

Raises:

CardanoError – If creation fails.

Return type:

VotingProcedure

Example

>>> procedure = VotingProcedure.new(Vote.YES)
>>> procedure = VotingProcedure.new(Vote.NO, anchor=my_anchor)
classmethod from_cbor(reader)[source]

Deserializes a VotingProcedure from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the voting procedure data.

Returns:

A new VotingProcedure deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

VotingProcedure

to_cbor(writer)[source]

Serializes the voting procedure 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]

Serializes the voting procedure to CIP-116 JSON format.

The function writes the full JSON object, including the surrounding braces. Keys are written in the order: “vote”, then “anchor” (if present).

Parameters:

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

Raises:

CardanoError – If serialization fails.

Return type:

None

Example

>>> from cometa.voting_procedures import VotingProcedure, Vote
>>> from cometa.json import JsonWriter
>>> procedure = VotingProcedure.new(Vote.YES)
>>> writer = JsonWriter()
>>> procedure.to_cip116_json(writer)
>>> print(writer.encode())
{"vote":"yes"}
property vote: Vote

Returns the vote choice.

property anchor: Anchor | None

Returns the anchor, or None if not set.