Proposal Procedure

typedef struct cardano_proposal_procedure_t cardano_proposal_procedure_t

Governance proposal procedure for the Cardano blockchain, it supports various types of governance actions.


cardano_error_t cardano_proposal_procedure_new_parameter_change_action(uint64_t deposit, cardano_reward_address_t *reward_address, cardano_anchor_t *anchor, cardano_parameter_change_action_t *parameter_change_action, cardano_proposal_procedure_t **proposal)

Creates a new proposal procedure for a parameter change action.

This function allocates and initializes a new instance of a cardano_proposal_procedure_t object, which is designed to propose changes to the protocol parameters within the Cardano network.

Usage Example:

uint64_t deposit = 1000000; // Example deposit amount
cardano_reward_address_t* reward_address = cardano_reward_address_new(...); // Assume initialized
cardano_anchor_t* anchor = cardano_anchor_new(...); // Optionally initialized
cardano_parameter_change_action_t* parameter_change_action = cardano_parameter_change_action_new(...); // Assume initialized
cardano_proposal_procedure_t* proposal = NULL;
cardano_error_t result = cardano_proposal_procedure_new_parameter_change_action(deposit, reward_address, anchor, parameter_change_action, &proposal);

if (result == CARDANO_SUCCESS)
{
  // Use the proposal procedure
  // Free resources when done
  cardano_proposal_procedure_unref(&proposal);
}
else
{
  printf("Failed to create the proposal procedure: %s\n", cardano_error_to_string(result));
}

// Cleanup resources used for setup
cardano_reward_address_unref(&reward_address);
cardano_anchor_unref(&anchor);
cardano_parameter_change_action_unref(&parameter_change_action);

Parameters:
uint64_t deposit

[in] The deposit required to submit the proposal.

cardano_reward_address_t *reward_address

[in] A pointer to a cardano_reward_address_t object associated.

cardano_anchor_t *anchor

[in] A pointer to a cardano_anchor_t object representing additional information related to the proposal, can be NULL if not applicable.

cardano_parameter_change_action_t *parameter_change_action

[in] A pointer to an initialized cardano_parameter_change_action_t object detailing the proposed changes to protocol parameters.

cardano_proposal_procedure_t **proposal

[out] On successful initialization, this will point to a newly created cardano_proposal_procedure_t object. This object represents a “strong reference” to the proposal procedure, meaning that it is fully initialized and ready for use. The caller is responsible for managing the lifecycle of this object, specifically, once the proposal procedure is no longer needed, the caller must release it by calling cardano_proposal_procedure_unref.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the proposal procedure was successfully created, or an appropriate error code indicating the failure reason.


cardano_error_t cardano_proposal_procedure_new_hard_fork_initiation_action(uint64_t deposit, cardano_reward_address_t *reward_address, cardano_anchor_t *anchor, cardano_hard_fork_initiation_action_t *hard_fork_initiation_action, cardano_proposal_procedure_t **proposal)

Creates a new proposal procedure for a hard fork initiation action.

This function allocates and initializes a new instance of a cardano_proposal_procedure_t object.

Usage Example:

uint64_t deposit = 1000000; // Example deposit amount
cardano_reward_address_t* reward_address = cardano_reward_address_new(...); // Assume reward address is already initialized
cardano_anchor_t* anchor = cardano_anchor_new(...); // Optionally initialized
cardano_hard_fork_initiation_action_t* hard_fork_initiation_action = cardano_hard_fork_initiation_action_new(...); // Assume initialized
cardano_proposal_procedure_t* proposal = NULL;
cardano_error_t result = cardano_proposal_procedure_new_hard_fork_initiation_action(deposit, reward_address, anchor, hard_fork_initiation_action, &proposal);

if (result == CARDANO_SUCCESS)
{
  // Use the proposal procedure for hard fork initiation
  // Free resources when done
  cardano_proposal_procedure_unref(&proposal);
}
else
{
  printf("Failed to create the hard fork initiation proposal: %s\n", cardano_error_to_string(result));
}

// Cleanup resources used for setup
cardano_reward_address_unref(&reward_address);
cardano_anchor_unref(&anchor);
cardano_hard_fork_initiation_action_unref(&hard_fork_initiation_action);

Parameters:
uint64_t deposit

[in] The deposit required to submit the proposal.

cardano_reward_address_t *reward_address

[in] A pointer to a cardano_reward_address_t object associated.

cardano_anchor_t *anchor

[in] A pointer to a cardano_anchor_t object representing additional information related to the proposal, can be NULL if not applicable.

cardano_hard_fork_initiation_action_t *hard_fork_initiation_action

[in] A pointer to an initialized cardano_hard_fork_initiation_action_t object detailing the proposed hard fork.

cardano_proposal_procedure_t **proposal

[out] On successful initialization, this will point to a newly created cardano_proposal_procedure_t object. This object represents a “strong reference” to the proposal procedure, meaning that it is fully initialized and ready for use. The caller is responsible for managing the lifecycle of this object, specifically, once the proposal procedure is no longer needed, the caller must release it by calling cardano_proposal_procedure_unref.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the proposal procedure was successfully created, or an appropriate error code indicating the failure reason.


cardano_error_t cardano_proposal_procedure_new_treasury_withdrawals_action(uint64_t deposit, cardano_reward_address_t *reward_address, cardano_anchor_t *anchor, cardano_treasury_withdrawals_action_t *treasury_withdrawals_action, cardano_proposal_procedure_t **proposal)

Creates a new proposal procedure for a treasury withdrawals action.

This function allocates and initializes a new instance of a cardano_proposal_procedure_t object.

Usage Example:

uint64_t deposit = 1000000; // Example deposit amount
cardano_reward_address_t* reward_address = cardano_reward_address_new(...); // Assume reward address is already initialized
cardano_anchor_t* anchor = cardano_anchor_new(...); // Optionally initialized
cardano_treasury_withdrawals_action_t* treasury_withdrawals_action = cardano_treasury_withdrawals_action_new(...); // Assume initialized
cardano_proposal_procedure_t* proposal = NULL;
cardano_error_t result = cardano_proposal_procedure_new_treasury_withdrawals_action(deposit, reward_address, anchor, treasury_withdrawals_action, &proposal);

if (result == CARDANO_SUCCESS)
{
  // Use the proposal procedure for treasury withdrawals
  // Free resources when done
  cardano_proposal_procedure_unref(&proposal);
}
else
{
  printf("Failed to create the treasury withdrawals proposal: %s\n", cardano_error_to_string(result));
}

// Cleanup resources used for setup
cardano_reward_address_unref(&reward_address);
cardano_anchor_unref(&anchor);
cardano_treasury_withdrawals_action_unref(&treasury_withdrawals_action);

Parameters:
uint64_t deposit

[in] The deposit required to submit the proposal.

cardano_reward_address_t *reward_address

[in] A pointer to a cardano_reward_address_t object associated.

cardano_anchor_t *anchor

[in] A pointer to a cardano_anchor_t object representing additional information related to the proposal, can be NULL if not applicable.

cardano_treasury_withdrawals_action_t *treasury_withdrawals_action

[in] A pointer to an initialized cardano_treasury_withdrawals_action_t object detailing the proposed hard fork.

cardano_proposal_procedure_t **proposal

[out] On successful initialization, this will point to a newly created cardano_proposal_procedure_t object. This object represents a “strong reference” to the proposal procedure, meaning that it is fully initialized and ready for use. The caller is responsible for managing the lifecycle of this object, specifically, once the proposal procedure is no longer needed, the caller must release it by calling cardano_proposal_procedure_unref.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the proposal procedure was successfully created, or an appropriate error code indicating the failure reason.


cardano_error_t cardano_proposal_procedure_new_no_confidence_action(uint64_t deposit, cardano_reward_address_t *reward_address, cardano_anchor_t *anchor, cardano_no_confidence_action_t *no_confidence_action, cardano_proposal_procedure_t **proposal)

Creates a new proposal procedure for a no confidence action.

This function allocates and initializes a new instance of a cardano_proposal_procedure_t object.

Usage Example:

uint64_t deposit = 1000000; // Example deposit amount
cardano_reward_address_t* reward_address = cardano_reward_address_new(...); // Assume reward address is already initialized
cardano_anchor_t* anchor = cardano_anchor_new(...); // Optionally initialized
cardano_no_confidence_action_t* no_confidence_action = cardano_no_confidence_action_new(...); // Assume initialized
cardano_proposal_procedure_t* proposal = NULL;
cardano_error_t result = cardano_proposal_procedure_new_no_confidence_action(deposit, reward_address, anchor, no_confidence_action, &proposal);

if (result == CARDANO_SUCCESS)
{
  // Use the proposal procedure for no confidence
  // Free resources when done
  cardano_proposal_procedure_unref(&proposal);
}
else
{
  printf("Failed to create the no confidence proposal: %s\n", cardano_error_to_string(result));
}

// Cleanup resources used for setup
cardano_reward_address_unref(&reward_address);
cardano_anchor_unref(&anchor);
cardano_no_confidence_action_unref(&no_confidence_action);

Parameters:
uint64_t deposit

[in] The deposit required to submit the proposal.

cardano_reward_address_t *reward_address

[in] A pointer to a cardano_reward_address_t object associated.

cardano_anchor_t *anchor

[in] A pointer to a cardano_anchor_t object representing additional information related to the proposal, can be NULL if not applicable.

cardano_no_confidence_action_t *no_confidence_action

[in] A pointer to an initialized cardano_no_confidence_action_t object detailing the proposed hard fork.

cardano_proposal_procedure_t **proposal

[out] On successful initialization, this will point to a newly created cardano_proposal_procedure_t object. This object represents a “strong reference” to the proposal procedure, meaning that it is fully initialized and ready for use. The caller is responsible for managing the lifecycle of this object, specifically, once the proposal procedure is no longer needed, the caller must release it by calling cardano_proposal_procedure_unref.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the proposal procedure was successfully created, or an appropriate error code indicating the failure reason.


cardano_error_t cardano_proposal_procedure_new_update_committee_action(uint64_t deposit, cardano_reward_address_t *reward_address, cardano_anchor_t *anchor, cardano_update_committee_action_t *update_committee_action, cardano_proposal_procedure_t **proposal)

Creates a new proposal procedure for a update committee action.

This function allocates and initializes a new instance of a cardano_proposal_procedure_t object.

Usage Example:

uint64_t deposit = 1000000; // Example deposit amount
cardano_reward_address_t* reward_address = cardano_reward_address_new(...); // Assume reward address is already initialized
cardano_anchor_t* anchor = cardano_anchor_new(...); // Optionally initialized
cardano_update_committee_action_t* update_committee_action = cardano_update_committee_action_new(...); // Assume initialized
cardano_proposal_procedure_t* proposal = NULL;
cardano_error_t result = cardano_proposal_procedure_new_update_committee_action(deposit, reward_address, anchor, update_committee_action, &proposal);

if (result == CARDANO_SUCCESS)
{
  // Use the proposal procedure for update committee
  // Free resources when done
  cardano_proposal_procedure_unref(&proposal);
}
else
{
  printf("Failed to create the update committee proposal: %s\n", cardano_error_to_string(result));
}

// Cleanup resources used for setup
cardano_reward_address_unref(&reward_address);
cardano_anchor_unref(&anchor);
cardano_update_committee_action_unref(&update_committee_action);

Parameters:
uint64_t deposit

[in] The deposit required to submit the proposal.

cardano_reward_address_t *reward_address

[in] A pointer to a cardano_reward_address_t object associated.

cardano_anchor_t *anchor

[in] A pointer to a cardano_anchor_t object representing additional information related to the proposal, can be NULL if not applicable.

cardano_update_committee_action_t *update_committee_action

[in] A pointer to an initialized cardano_update_committee_action_t object detailing the proposed hard fork.

cardano_proposal_procedure_t **proposal

[out] On successful initialization, this will point to a newly created cardano_proposal_procedure_t object. This object represents a “strong reference” to the proposal procedure, meaning that it is fully initialized and ready for use. The caller is responsible for managing the lifecycle of this object, specifically, once the proposal procedure is no longer needed, the caller must release it by calling cardano_proposal_procedure_unref.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the proposal procedure was successfully created, or an appropriate error code indicating the failure reason.


cardano_error_t cardano_proposal_procedure_new_constitution_action(uint64_t deposit, cardano_reward_address_t *reward_address, cardano_anchor_t *anchor, cardano_new_constitution_action_t *new_constitution_action, cardano_proposal_procedure_t **proposal)

Creates a new proposal procedure for a new constitution action.

This function allocates and initializes a new instance of a cardano_proposal_procedure_t object.

Usage Example:

uint64_t deposit = 1000000; // Example deposit amount
cardano_reward_address_t* reward_address = cardano_reward_address_new(...); // Assume reward address is already initialized
cardano_anchor_t* anchor = cardano_anchor_new(...); // Optionally initialized
cardano_new_constitution_action_t* new_constitution_action = cardano_new_constitution_action_new(...); // Assume initialized
cardano_proposal_procedure_t* proposal = NULL;
cardano_error_t result = cardano_proposal_procedure_new_new_constitution_action(deposit, reward_address, anchor, new_constitution_action, &proposal);

if (result == CARDANO_SUCCESS)
{
  // Use the proposal procedure for new constitution
  // Free resources when done
  cardano_proposal_procedure_unref(&proposal);
}
else
{
  printf("Failed to create the new constitution proposal: %s\n", cardano_error_to_string(result));
}

// Cleanup resources used for setup
cardano_reward_address_unref(&reward_address);
cardano_anchor_unref(&anchor);
cardano_new_constitution_action_unref(&new_constitution_action);

Parameters:
uint64_t deposit

[in] The deposit required to submit the proposal.

cardano_reward_address_t *reward_address

[in] A pointer to a cardano_reward_address_t object associated.

cardano_anchor_t *anchor

[in] A pointer to a cardano_anchor_t object representing additional information related to the proposal, can be NULL if not applicable.

cardano_new_constitution_action_t *new_constitution_action

[in] A pointer to an initialized cardano_new_constitution_action_t object detailing the proposed hard fork.

cardano_proposal_procedure_t **proposal

[out] On successful initialization, this will point to a newly created cardano_proposal_procedure_t object. This object represents a “strong reference” to the proposal procedure, meaning that it is fully initialized and ready for use. The caller is responsible for managing the lifecycle of this object, specifically, once the proposal procedure is no longer needed, the caller must release it by calling cardano_proposal_procedure_unref.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the proposal procedure was successfully created, or an appropriate error code indicating the failure reason.


cardano_error_t cardano_proposal_procedure_new_info_action(uint64_t deposit, cardano_reward_address_t *reward_address, cardano_anchor_t *anchor, cardano_info_action_t *info_action, cardano_proposal_procedure_t **proposal)

Creates a new proposal procedure for a info action.

This function allocates and initializes a new instance of a cardano_proposal_procedure_t object.

Usage Example:

uint64_t deposit = 1000000; // Example deposit amount
cardano_reward_address_t* reward_address = cardano_reward_address_new(...); // Assume reward address is already initialized
cardano_anchor_t* anchor = cardano_anchor_new(...); // Optionally initialized
cardano_info_action_t* info_action = cardano_info_action_new(...); // Assume initialized
cardano_proposal_procedure_t* proposal = NULL;
cardano_error_t result = cardano_proposal_procedure_new_info_action(deposit, reward_address, anchor, info_action, &proposal);

if (result == CARDANO_SUCCESS)
{
  // Use the proposal procedure for info
  // Free resources when done
  cardano_proposal_procedure_unref(&proposal);
}
else
{
  printf("Failed to create the info proposal: %s\n", cardano_error_to_string(result));
}

// Cleanup resources used for setup
cardano_reward_address_unref(&reward_address);
cardano_anchor_unref(&anchor);
cardano_info_action_unref(&info_action);

Parameters:
uint64_t deposit

[in] The deposit required to submit the proposal.

cardano_reward_address_t *reward_address

[in] A pointer to a cardano_reward_address_t object associated.

cardano_anchor_t *anchor

[in] A pointer to a cardano_anchor_t object representing additional information related to the proposal, can be NULL if not applicable.

cardano_info_action_t *info_action

[in] A pointer to an initialized cardano_info_action_t object detailing the proposed hard fork.

cardano_proposal_procedure_t **proposal

[out] On successful initialization, this will point to a newly created cardano_proposal_procedure_t object. This object represents a “strong reference” to the proposal procedure, meaning that it is fully initialized and ready for use. The caller is responsible for managing the lifecycle of this object, specifically, once the proposal procedure is no longer needed, the caller must release it by calling cardano_proposal_procedure_unref.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the proposal procedure was successfully created, or an appropriate error code indicating the failure reason.


cardano_error_t cardano_proposal_procedure_from_cbor(cardano_cbor_reader_t *reader, cardano_proposal_procedure_t **auth_committee_hot)

Creates a cardano_proposal_procedure_t from a CBOR reader.

This function parses CBOR data using a provided cardano_cbor_reader_t and constructs a cardano_proposal_procedure_t object. It assumes that the CBOR reader is set up correctly and that the CBOR data corresponds to the structure expected for a auth_committee_hot.

Usage Example:

cardano_cbor_reader_t* reader = cardano_cbor_reader_new(cbor_data, data_size);
cardano_proposal_procedure_t* auth_committee_hot = NULL;

cardano_error_t result = cardano_proposal_procedure_from_cbor(reader, &auth_committee_hot);

if (result == CARDANO_SUCCESS)
{
  // Use the auth_committee_hot

  // Once done, ensure to clean up and release the auth_committee_hot
  cardano_proposal_procedure_unref(&auth_committee_hot);
}
else
{
  const char* error = cardano_cbor_reader_get_last_error(reader);
  printf("Failed to decode auth_committee_hot: %s\n", error);
}

cardano_cbor_reader_unref(&reader); // Cleanup the CBOR reader

Note

If the function fails, the last error can be retrieved by calling cardano_cbor_reader_get_last_error with the reader. The caller is responsible for freeing the created cardano_proposal_procedure_t object by calling cardano_proposal_procedure_unref when it is no longer needed.

Parameters:
cardano_cbor_reader_t *reader

[in] A pointer to an initialized cardano_cbor_reader_t that is ready to read the CBOR-encoded data.

cardano_proposal_procedure_t **auth_committee_hot

[out] A pointer to a pointer of cardano_proposal_procedure_t that will be set to the address of the newly created auth_committee_hot object upon successful decoding.

Returns:

A cardano_error_t value indicating the outcome of the operation. Returns CARDANO_SUCCESS if the object was successfully created, or an appropriate error code if an error occurred.


cardano_error_t cardano_proposal_procedure_to_cbor(const cardano_proposal_procedure_t *auth_committee_hot, cardano_cbor_writer_t *writer)

Serializes the proposal_procedure into CBOR format using a CBOR writer.

This function serializes the given cardano_proposal_procedure_t object using a cardano_cbor_writer_t.

Usage Example:

cardano_proposal_procedure_t* auth_committee_hot = ...;
cardano_cbor_writer_t* writer = cardano_cbor_writer_new();

if (writer)
{
  cardano_error_t result = cardano_proposal_procedure_to_cbor(auth_committee_hot, writer);

  if (result == CARDANO_SUCCESS)
  {
    // Use the writer's buffer containing the serialized data
  }
  else
  {
    const char* error_message = cardano_cbor_writer_get_last_error(writer);
    printf("Serialization failed: %s\n", error_message);
  }

  cardano_cbor_writer_unref(&writer);
}

cardano_proposal_procedure_unref(&auth_committee_hot);

Parameters:
const cardano_proposal_procedure_t *auth_committee_hot

[in] A constant pointer to the cardano_proposal_procedure_t object that is to be serialized.

cardano_cbor_writer_t *writer

[out] A pointer to a cardano_cbor_writer_t where the CBOR serialized data will be written. The writer must already be initialized and ready to accept the data.

Returns:

Returns CARDANO_SUCCESS if the serialization is successful. If the auth_committee_hot or writer is NULL, returns CARDANO_ERROR_POINTER_IS_NULL.


cardano_error_t cardano_proposal_procedure_to_cip116_json(const cardano_proposal_procedure_t *procedure, cardano_json_writer_t *writer)

Serializes a proposal procedure to CIP-116 JSON.

The function writes the full JSON object, including the surrounding braces. Keys are written in the order: “deposit”, “reward_account”, “gov_action”, “anchor”.

Parameters:
const cardano_proposal_procedure_t *procedure

[in] Pointer to a valid cardano_proposal_procedure_t.

cardano_json_writer_t *writer

[in] Pointer to a valid cardano_json_writer_t.

Returns:

CARDANO_SUCCESS On success. CARDANO_ERROR_POINTER_IS_NULL If procedure or writer is NULL. CARDANO_ERROR_MEMORY_ALLOCATION_FAILED If memory allocation fails. Other Any error propagated from nested writers.


cardano_error_t cardano_proposal_procedure_get_action_type(const cardano_proposal_procedure_t *proposal, cardano_governance_action_type_t *type)

Retrieves the type of governance action associated with a proposal procedure.

This function extracts the type of governance action, represented by a cardano_governance_action_id_t object, from a given cardano_proposal_procedure_t object.

Usage Example:

cardano_proposal_procedure_t* proposal = cardano_proposal_procedure_new(...);
cardano_governance_action_id_t type;
cardano_error_t result = cardano_proposal_procedure_get_action_type(proposal, &type);

if (result == CARDANO_SUCCESS)
{
  printf("Action Type: %d\n", type);
  // Handle the action type accordingly
}

// Clean up the proposal object once done
cardano_proposal_procedure_unref(&proposal);

Parameters:
const cardano_proposal_procedure_t *proposal

[in] A constant pointer to the cardano_proposal_procedure_t object from which the action type is to be retrieved. The object must not be NULL.

cardano_governance_action_type_t *type

[out] Pointer to a variable where the action type will be stored. This variable will be set to the value from the cardano_governance_action_id_t enumeration.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the action type was successfully retrieved, or an appropriate error code if the input is NULL or any other error occurs.


cardano_error_t cardano_proposal_procedure_to_parameter_change_action(cardano_proposal_procedure_t *proposal, cardano_parameter_change_action_t **parameter_change_action)

Converts a proposal procedure into a parameter change action if applicable.

This function attempts to convert a given cardano_proposal_procedure_t object into a cardano_parameter_change_action_t object. This is applicable only if the proposal procedure encapsulates a parameter change action.

Usage Example:

cardano_proposal_procedure_t* proposal = cardano_proposal_procedure_new(...);
cardano_parameter_change_action_t* parameter_change_action = NULL;
cardano_error_t result = cardano_proposal_procedure_to_parameter_change_action(proposal, &parameter_change_action);

if (result == CARDANO_SUCCESS)
{
  // Successfully retrieved the parameter change action
  // Use the parameter_change_action as needed

  // Clean up the parameter change action when done
  cardano_parameter_change_action_unref(&parameter_change_action);
}
else
{
  printf("Failed to convert to parameter change action: %s\n", cardano_error_to_string(result));
}

// Clean up the proposal object after use
cardano_proposal_procedure_unref(&proposal);

Parameters:
cardano_proposal_procedure_t *proposal

[in] A pointer to the cardano_proposal_procedure_t object that potentially contains a parameter change action.

cardano_parameter_change_action_t **parameter_change_action

[out] On successful conversion, this will point to a newly created cardano_parameter_change_action_t object representing the parameter change action. The caller is responsible for managing the lifecycle of this object, including releasing it by calling cardano_parameter_change_action_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code if the proposal does not contain a parameter change action or if any other error occurs.


cardano_error_t cardano_proposal_procedure_to_hard_fork_initiation_action(cardano_proposal_procedure_t *proposal, cardano_hard_fork_initiation_action_t **hard_fork_initiation_action)

Converts a proposal procedure into a hard fork initiation action if applicable.

This function attempts to convert a given cardano_proposal_procedure_t object into a cardano_hard_fork_initiation_action_t object. This is applicable only if the proposal procedure encapsulates a hard fork initiation action.

Usage Example:

cardano_proposal_procedure_t* proposal = cardano_proposal_procedure_new(...);
cardano_hard_fork_initiation_action_t* hard_fork_initiation_action = NULL;
cardano_error_t result = cardano_proposal_procedure_to_hard_fork_initiation_action(proposal, &hard_fork_initiation_action);

if (result == CARDANO_SUCCESS)
{
  // Successfully retrieved the hard fork initiation action
  // Use the hard_fork_initiation_action as needed

  // Clean up the hard fork initiation action when done
  cardano_hard_fork_initiation_action_unref(&hard_fork_initiation_action);
}
else
{
  printf("Failed to convert to hard fork initiation action: %s\n", cardano_error_to_string(result));
}

// Clean up the proposal object after use
cardano_proposal_procedure_unref(&proposal);

Parameters:
cardano_proposal_procedure_t *proposal

[in] A pointer to the cardano_proposal_procedure_t object that potentially contains a hard fork initiation action.

cardano_hard_fork_initiation_action_t **hard_fork_initiation_action

[out] On successful conversion, this will point to a newly created cardano_hard_fork_initiation_action_t object representing the hard fork initiation action. The caller is responsible for managing the lifecycle of this object, including releasing it by calling cardano_hard_fork_initiation_action_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code if the proposal does not contain a hard fork initiation action or if any other error occurs.


cardano_error_t cardano_proposal_procedure_to_treasury_withdrawals_action(cardano_proposal_procedure_t *proposal, cardano_treasury_withdrawals_action_t **treasury_withdrawals_action)

Converts a proposal procedure into a treasury withdrawals action if applicable.

This function attempts to convert a given cardano_proposal_procedure_t object into a cardano_treasury_withdrawals_action_t object. This is applicable only if the proposal procedure encapsulates a treasury withdrawals action.

Usage Example:

cardano_proposal_procedure_t* proposal = cardano_proposal_procedure_new(...);
cardano_treasury_withdrawals_action_t* treasury_withdrawals_action = NULL;
cardano_error_t result = cardano_proposal_procedure_to_treasury_withdrawals_action(proposal, &treasury_withdrawals_action);

if (result == CARDANO_SUCCESS)
{
  // Successfully retrieved the treasury withdrawals action
  // Use the treasury_withdrawals_action as needed

  // Clean up the treasury withdrawals action when done
  cardano_treasury_withdrawals_action_unref(&treasury_withdrawals_action);
}
else
{
  printf("Failed to convert to treasury withdrawals action: %s\n", cardano_error_to_string(result));
}

// Clean up the proposal object after use
cardano_proposal_procedure_unref(&proposal);

Parameters:
cardano_proposal_procedure_t *proposal

[in] A pointer to the cardano_proposal_procedure_t object that potentially contains a treasury withdrawals action.

cardano_treasury_withdrawals_action_t **treasury_withdrawals_action

[out] On successful conversion, this will point to a newly created cardano_treasury_withdrawals_action_t object representing the treasury withdrawals action. The caller is responsible for managing the lifecycle of this object, including releasing it by calling cardano_treasury_withdrawals_action_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code if the proposal does not contain a treasury withdrawals action or if any other error occurs.


cardano_error_t cardano_proposal_procedure_to_no_confidence_action(cardano_proposal_procedure_t *proposal, cardano_no_confidence_action_t **no_confidence_action)

Converts a proposal procedure into a no confidence action if applicable.

This function attempts to convert a given cardano_proposal_procedure_t object into a cardano_no_confidence_action_t object. This is applicable only if the proposal procedure encapsulates a no confidence action.

Usage Example:

cardano_proposal_procedure_t* proposal = cardano_proposal_procedure_new(...);
cardano_no_confidence_action_t* no_confidence_action = NULL;
cardano_error_t result = cardano_proposal_procedure_to_no_confidence_action(proposal, &no_confidence_action);

if (result == CARDANO_SUCCESS)
{
  // Successfully retrieved the no confidence action
  // Use the no_confidence_action as needed

  // Clean up the no confidence action when done
  cardano_no_confidence_action_unref(&no_confidence_action);
}
else
{
  printf("Failed to convert to no confidence action: %s\n", cardano_error_to_string(result));
}

// Clean up the proposal object after use
cardano_proposal_procedure_unref(&proposal);

Parameters:
cardano_proposal_procedure_t *proposal

[in] A pointer to the cardano_proposal_procedure_t object that potentially contains a no confidence action.

cardano_no_confidence_action_t **no_confidence_action

[out] On successful conversion, this will point to a newly created cardano_no_confidence_action_t object representing the no confidence action. The caller is responsible for managing the lifecycle of this object, including releasing it by calling cardano_no_confidence_action_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code if the proposal does not contain a no confidence action or if any other error occurs.


cardano_error_t cardano_proposal_procedure_to_update_committee_action(cardano_proposal_procedure_t *proposal, cardano_update_committee_action_t **update_committee_action)

Converts a proposal procedure into an update committee action if applicable.

This function attempts to convert a given cardano_proposal_procedure_t object into a cardano_update_committee_action_t object. This is applicable only if the proposal procedure encapsulates an update committee action.

Usage Example:

cardano_proposal_procedure_t* proposal = cardano_proposal_procedure_new(...);
cardano_update_committee_action_t* update_committee_action = NULL;
cardano_error_t result = cardano_proposal_procedure_to_update_committee_action(proposal, &update_committee_action);

if (result == CARDANO_SUCCESS)
{
  // Successfully retrieved the update committee action
  // Use the update_committee_action as needed

  // Clean up the update committee action when done
  cardano_update_committee_action_unref(&update_committee_action);
}
else
{
  printf("Failed to convert to update committee action: %s\n", cardano_error_to_string(result));
}

// Clean up the proposal object after use
cardano_proposal_procedure_unref(&proposal);

Parameters:
cardano_proposal_procedure_t *proposal

[in] A pointer to the cardano_proposal_procedure_t object that potentially contains an update committee action.

cardano_update_committee_action_t **update_committee_action

[out] On successful conversion, this will point to a newly created cardano_update_committee_action_t object representing the update committee action. The caller is responsible for managing the lifecycle of this object, including releasing it by calling cardano_update_committee_action_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code if the proposal does not contain an update committee action or if any other error occurs.


cardano_error_t cardano_proposal_procedure_to_constitution_action(cardano_proposal_procedure_t *proposal, cardano_new_constitution_action_t **constitution_action)

Converts a proposal procedure into a new constitution action if applicable.

This function attempts to convert a given cardano_proposal_procedure_t object into a cardano_new_constitution_action_t object. This is applicable only if the proposal procedure encapsulates a new constitution action.

Usage Example:

cardano_proposal_procedure_t* proposal = cardano_proposal_procedure_new(...);
cardano_new_constitution_action_t* constitution_action = NULL;
cardano_error_t result = cardano_proposal_procedure_to_constitution_action(proposal, &constitution_action);

if (result == CARDANO_SUCCESS)
{
  // Successfully retrieved the new constitution action
  // Use the constitution_action as needed

  // Clean up the new constitution action when done
  cardano_new_constitution_action_unref(&constitution_action);
}
else
{
  printf("Failed to convert to new constitution action: %s\n", cardano_error_to_string(result));
}

// Clean up the proposal object after use
cardano_proposal_procedure_unref(&proposal);

Parameters:
cardano_proposal_procedure_t *proposal

[in] A pointer to the cardano_proposal_procedure_t object that potentially contains a new constitution action.

cardano_new_constitution_action_t **constitution_action

[out] On successful conversion, this will point to a newly created cardano_new_constitution_action_t object representing the new constitution action. The caller is responsible for managing the lifecycle of this object, including releasing it by calling cardano_new_constitution_action_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code if the proposal does not contain a new constitution action or if any other error occurs.


cardano_error_t cardano_proposal_procedure_to_info_action(cardano_proposal_procedure_t *proposal, cardano_info_action_t **info_action)

Converts a proposal procedure into an info action if applicable.

This function attempts to convert a given cardano_proposal_procedure_t object into a cardano_info_action_t object. This is applicable only if the proposal procedure encapsulates an info action, which is intended for recording informative notices on the blockchain without directly affecting its operational state.

Usage Example:

cardano_proposal_procedure_t* proposal = cardano_proposal_procedure_new(...);
cardano_info_action_t* info_action = NULL;
cardano_error_t result = cardano_proposal_procedure_to_info_action(proposal, &info_action);

if (result == CARDANO_SUCCESS)
{
  // Successfully retrieved the info action
  // Use the info_action as needed

  // Clean up the info action when done
  cardano_info_action_unref(&info_action);
}
else
{
  printf("Failed to convert to info action: %s\n", cardano_error_to_string(result));
}

// Clean up the proposal object after use
cardano_proposal_procedure_unref(&proposal);

Parameters:
cardano_proposal_procedure_t *proposal

[in] A pointer to the cardano_proposal_procedure_t object that potentially contains an info action.

cardano_info_action_t **info_action

[out] On successful conversion, this will point to a newly created cardano_info_action_t object representing the info action. The caller is responsible for managing the lifecycle of this object, including releasing it by calling cardano_info_action_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code if the proposal does not contain an info action or if any other error occurs.


cardano_error_t cardano_proposal_procedure_set_anchor(cardano_proposal_procedure_t *proposal_procedure, cardano_anchor_t *anchor)

Sets the anchor in the proposal procedure.

This function updates the anchor of a cardano_proposal_procedure_t object. The anchor is used to link to the off-chain content of the proposal_procedure.

Usage Example:

cardano_proposal_procedure_t* proposal_procedure = ...; // Assume proposal_procedure is already initialized
cardano_anchor_t* anchor = cardano_anchor_new(...); // Assume anchor is already initialized

cardano_error_t result = cardano_proposal_procedure_set_anchor(proposal_procedure, anchor);
if (result == CARDANO_SUCCESS)
{
  // The anchor is now set for the proposal_procedure
}
else
{
  printf("Failed to set the anchor.\n");
}
// Clean up the proposal_procedure and anchor after use
cardano_proposal_procedure_unref(&proposal_procedure);
cardano_anchor_unref(&anchor);

Parameters:
cardano_proposal_procedure_t *proposal_procedure

[inout] A pointer to an initialized cardano_proposal_procedure_t object to which the anchor will be set.

cardano_anchor_t *anchor

[in] A pointer to an initialized cardano_anchor_t object representing the new anchor.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the anchor was successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if any of the input pointers are NULL.


cardano_anchor_t *cardano_proposal_procedure_get_anchor(cardano_proposal_procedure_t *proposal_procedure)

Gets the anchor from a proposal_procedure.

This function retrieves the anchor from a given cardano_proposal_procedure_t object. The anchor links to the off-chain content of the proposal_procedure.

Usage Example:

cardano_proposal_procedure_t* proposal_procedure = ...; // Assume initialized
cardano_anchor_t* anchor = cardano_proposal_procedure_get_anchor(proposal_procedure);

if (anchor != NULL)
{
  // Use the anchor

  // Once done, ensure to clean up and release the anchor
  cardano_anchor_unref(&anchor);
}
else
{
  printf("ERROR: No anchor set for this proposal_procedure.\n");
}

Parameters:
cardano_proposal_procedure_t *proposal_procedure

[in] A pointer to an initialized cardano_proposal_procedure_t object from which the anchor is retrieved.

Returns:

A pointer to the retrieved cardano_anchor_t object representing the anchor. This will be a new reference, and the caller is responsible for releasing it with cardano_anchor_unref when it is no longer needed. If the proposal_procedure does not have an anchor set, NULL is returned.


cardano_error_t cardano_proposal_procedure_set_reward_address(cardano_proposal_procedure_t *proposal_procedure, cardano_reward_address_t *reward_address)

Sets the reward address in the proposal procedure.

This function updates the reward_address of a cardano_proposal_procedure_t object.

Usage Example:

cardano_proposal_procedure_t* proposal_procedure = ...; // Assume proposal_procedure is already initialized
cardano_reward_address_t* reward_address = cardano_reward_address_new(...); // Assume reward_address is already initialized

cardano_error_t result = cardano_proposal_procedure_set_reward_address(proposal_procedure, reward_address);
if (result == CARDANO_SUCCESS)
{
  // The reward_address is now set for the proposal_procedure
}
else
{
  printf("Failed to set the reward_address.\n");
}
// Clean up the proposal_procedure and reward_address after use
cardano_proposal_procedure_unref(&proposal_procedure);
cardano_reward_address_unref(&reward_address);

Parameters:
cardano_proposal_procedure_t *proposal_procedure

[inout] A pointer to an initialized cardano_proposal_procedure_t object to which the reward address will be set.

cardano_reward_address_t *reward_address

[in] A pointer to an initialized cardano_reward_address_t object representing the new reward address.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the reward_address was successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if any of the input pointers are NULL.


cardano_reward_address_t *cardano_proposal_procedure_get_reward_address(cardano_proposal_procedure_t *proposal_procedure)

Gets the reward address from a proposal_procedure.

This function retrieves the reward address from a given cardano_proposal_procedure_t object.

Usage Example:

cardano_proposal_procedure_t* proposal_procedure = ...; // Assume initialized
cardano_reward_address_t* reward_address = cardano_proposal_procedure_get_reward_address(proposal_procedure);

if (reward_address != NULL)
{
  // Use the reward_address

  // Once done, ensure to clean up and release the reward_address
  cardano_reward_address_unref(&reward_address);
}
else
{
  printf("ERROR: No reward_address set for this proposal_procedure.\n");
}

Parameters:
cardano_proposal_procedure_t *proposal_procedure

[in] A pointer to an initialized cardano_proposal_procedure_t object from which the reward_address is retrieved.

Returns:

A pointer to the retrieved cardano_reward_address_t object representing the reward address. This will be a new reference, and the caller is responsible for releasing it with cardano_reward_address_unref when it is no longer needed. If the proposal_procedure does not have an reward_address set, NULL is returned.


uint64_t cardano_proposal_procedure_get_deposit(const cardano_proposal_procedure_t *certificate)

Retrieves the deposit amount from an proposal procedure.

This function retrieves the deposit amount that was associated with the proposal procedure.

Usage Example:

const cardano_proposal_procedure_t* proposal_procedure = ...; // Assume proposal_procedure is already initialized

uint64_t deposit = cardano_proposal_procedure_get_deposit(proposal_procedure);
printf("Deposit for unregistration: %llu lovelaces\n", deposit);

Parameters:
const cardano_proposal_procedure_t *certificate

[in] A constant pointer to an initialized cardano_proposal_procedure_t object.

Returns:

The deposit amount in lovelaces. If the proposal procedure is NULL, the function will return 0, which should be handled appropriately by the caller to distinguish from a genuine deposit of 0 lovelaces.


cardano_error_t cardano_proposal_procedure_set_deposit(cardano_proposal_procedure_t *certificate, uint64_t deposit)

Sets the deposit amount for an proposal procedure.

This function sets the deposit amount required for unregistration of a stake credential.

Usage Example:

cardano_proposal_procedure_t* proposal_procedure = ...; // Assume proposal_procedure is already initialized
uint64_t deposit = 2000000;

cardano_error_t result = cardano_proposal_procedure_set_deposit(proposal_procedure, deposit);

if (result == CARDANO_SUCCESS)
{
  printf("Deposit set successfully.\n");
}
else
{
  printf("Failed to set deposit.\n");
}

Parameters:
cardano_proposal_procedure_t *certificate

[inout] A pointer to an initialized cardano_proposal_procedure_t object to which the deposit amount will be set.

uint64_t deposit

[in] The deposit amount in lovelaces to set for the unregistration.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the deposit amount was successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the input certificate pointer is NULL.


void cardano_proposal_procedure_unref(cardano_proposal_procedure_t **auth_committee_hot)

Decrements the reference count of a cardano_proposal_procedure_t object.

This function is responsible for managing the lifecycle of a cardano_proposal_procedure_t object by decreasing its reference count. When the reference count reaches zero, the auth_committee_hot is finalized; its associated resources are released, and its memory is deallocated.

Usage Example:

cardano_proposal_procedure_t* auth_committee_hot = cardano_proposal_procedure_new(major, minor);

// Perform operations with the auth_committee_hot...

cardano_proposal_procedure_unref(&auth_committee_hot);
// At this point, auth_committee_hot is NULL and cannot be used.

Note

After calling cardano_proposal_procedure_unref, the pointer to the cardano_proposal_procedure_t object will be set to NULL to prevent its reuse.

Parameters:
cardano_proposal_procedure_t **auth_committee_hot

[inout] A pointer to the pointer of the auth_committee_hot object. This double indirection allows the function to set the caller’s pointer to NULL, avoiding dangling pointer issues after the object has been freed.


void cardano_proposal_procedure_ref(cardano_proposal_procedure_t *auth_committee_hot)

Increases the reference count of the cardano_proposal_procedure_t object.

This function is used to manually increment the reference count of an cardano_proposal_procedure_t object, indicating that another part of the code has taken ownership of it. This ensures the object remains allocated and valid until all owners have released their reference by calling cardano_proposal_procedure_unref.

Usage Example:

// Assuming auth_committee_hot is a previously created auth_committee_hot object

cardano_proposal_procedure_ref(auth_committee_hot);

// Now auth_committee_hot can be safely used elsewhere without worrying about premature deallocation

Note

Always ensure that for every call to cardano_proposal_procedure_ref there is a corresponding call to cardano_proposal_procedure_unref to prevent memory leaks.

Parameters:
cardano_proposal_procedure_t *auth_committee_hot

A pointer to the cardano_proposal_procedure_t object whose reference count is to be incremented.


size_t cardano_proposal_procedure_refcount(const cardano_proposal_procedure_t *auth_committee_hot)

Retrieves the current reference count of the cardano_proposal_procedure_t object.

This function returns the number of active references to an cardano_proposal_procedure_t object. It’s useful for debugging purposes or managing the lifecycle of the object in complex scenarios.

Usage Example:

// Assuming auth_committee_hot is a previously created auth_committee_hot object

size_t ref_count = cardano_proposal_procedure_refcount(auth_committee_hot);

printf("Reference count: %zu\n", ref_count);

Warning

This function does not account for transitive references. A transitive reference occurs when an object holds a reference to another object, rather than directly to the cardano_proposal_procedure_t. As such, the reported count may not fully represent the total number of conceptual references in cases where such transitive relationships exist.

Parameters:
const cardano_proposal_procedure_t *auth_committee_hot

A pointer to the cardano_proposal_procedure_t object whose reference count is queried. The object must not be NULL.

Returns:

The number of active references to the specified cardano_proposal_procedure_t object. If the object is properly managed (i.e., every cardano_proposal_procedure_ref call is matched with a cardano_proposal_procedure_unref call), this count should reach zero right before the object is deallocated.


void cardano_proposal_procedure_set_last_error(cardano_proposal_procedure_t *auth_committee_hot, const char *message)

Sets the last error message for a given cardano_proposal_procedure_t object.

Records an error message in the auth_committee_hot’s last_error buffer, overwriting any existing message. This is useful for storing descriptive error information that can be later retrieved. The message is truncated if it exceeds the buffer’s capacity.

Note

The error message is limited to 1023 characters, including the null terminator, due to the fixed size of the last_error buffer.

Parameters:
cardano_proposal_procedure_t *auth_committee_hot

[in] A pointer to the cardano_proposal_procedure_t instance whose last error message is to be set. If NULL, the function does nothing.

const char *message

[in] A null-terminated string containing the error message. If NULL, the auth_committee_hot’s last_error is set to an empty string, indicating no error.


const char *cardano_proposal_procedure_get_last_error(const cardano_proposal_procedure_t *auth_committee_hot)

Retrieves the last error message recorded for a specific auth_committee_hot.

This function returns a pointer to the null-terminated string containing the last error message set by cardano_proposal_procedure_set_last_error for the given auth_committee_hot. If no error message has been set, or if the last_error buffer was explicitly cleared, an empty string is returned, indicating no error.

Note

The returned string points to internal storage within the object and must not be modified by the caller. The string remains valid until the next call to cardano_proposal_procedure_set_last_error for the same auth_committee_hot, or until the auth_committee_hot is deallocated.

Parameters:
const cardano_proposal_procedure_t *auth_committee_hot

[in] A pointer to the cardano_proposal_procedure_t instance whose last error message is to be retrieved. If the auth_committee_hot is NULL, the function returns a generic error message indicating the null auth_committee_hot.

Returns:

A pointer to a null-terminated string containing the last error message for the specified auth_committee_hot. If the auth_committee_hot is NULL, “Object is NULL.” is returned to indicate the error.