Certificate

typedef struct cardano_certificate_t cardano_certificate_t

Certificates are a means to encode various essential operations related to stake delegation and stake pool management.

Certificates are embedded in transactions and included in blocks. They’re a vital aspect of Cardano’s proof-of-stake mechanism, ensuring that stakeholders can participate in the protocol and its governance.


cardano_error_t cardano_certificate_new_auth_committee_hot(cardano_auth_committee_hot_cert_t *auth_committee_hot_cert, cardano_certificate_t **certificate)

Creates a new Cardano certificate based on an authorization committee hot certificate.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_auth_committee_hot_cert_t object.

Usage Example:

cardano_auth_committee_hot_cert_t* auth_cert = ...;  // Assume auth_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_auth_committee_hot(auth_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for authorization purposes in committee operations
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create authorization certificate: %s\n", cardano_error_to_string(result));
}

cardano_auth_committee_hot_cert_unref(&auth_cert); // Cleanup the auth_cert

Parameters:
cardano_auth_committee_hot_cert_t *auth_committee_hot_cert

[in] A pointer to an initialized cardano_auth_committee_hot_cert_t object that defines the committee’s hot certificate details.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_genesis_key_delegation(cardano_genesis_key_delegation_cert_t *genesis_key_delegation, cardano_certificate_t **certificate)

Creates a new Cardano certificate for genesis key delegation.

This function allocates and initializes a cardano_certificate_t object for the purpose of genesis key delegation, using the provided cardano_genesis_key_delegation_cert_t object which contains the delegation details.

Usage Example:

cardano_genesis_key_delegation_cert_t* genesis_cert = ...;  // Assume genesis_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_genesis_key_delegation(genesis_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for genesis key delegation operations
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create genesis key delegation certificate: %s\n", cardano_error_to_string(result));
}

cardano_genesis_key_delegation_cert_unref(&genesis_cert); // Cleanup the genesis_cert

Parameters:
cardano_genesis_key_delegation_cert_t *genesis_key_delegation

[in] A pointer to an initialized cardano_genesis_key_delegation_cert_t object that specifies the genesis key delegation parameters.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_mir(cardano_mir_cert_t *mir, cardano_certificate_t **certificate)

Creates a new Cardano certificate for Move Instantaneous Rewards (MIR).

This function allocates and initializes a cardano_certificate_t object for the purpose of managing Move Instantaneous Rewards, using the provided cardano_mir_cert_t object which contains the MIR details.

Usage Example:

cardano_mir_cert_t* mir_cert = ...;  // Assume mir_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_mir(mir_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for MIR operations
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create MIR certificate: %s\n", cardano_error_to_string(result));
}

cardano_mir_cert_unref(&mir_cert); // Cleanup the mir_cert

Parameters:
cardano_mir_cert_t *mir

[in] A pointer to an initialized cardano_mir_cert_t object that specifies the MIR parameters.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_pool_registration(cardano_pool_registration_cert_t *pool_registration, cardano_certificate_t **certificate)

Creates a new Cardano certificate for pool registration.

This function allocates and initializes a cardano_certificate_t object specifically for registering a staking pool, using the provided cardano_pool_registration_cert_t object which contains all the necessary parameters for pool registration.

Usage Example:

cardano_pool_registration_cert_t* registration_cert = ...;  // Assume registration_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_pool_registration(registration_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for pool registration purposes
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create pool registration certificate: %s\n", cardano_error_to_string(result));
}

cardano_pool_registration_cert_unref(&registration_cert); // Cleanup the registration_cert

Parameters:
cardano_pool_registration_cert_t *pool_registration

[in] A pointer to an initialized cardano_pool_registration_cert_t object that defines the staking pool’s registration details.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_pool_retirement(cardano_pool_retirement_cert_t *pool_retirement, cardano_certificate_t **certificate)

Creates a new Cardano certificate for pool retirement.

This function allocates and initializes a cardano_certificate_t object specifically for the retirement of a staking pool, using the provided cardano_pool_retirement_cert_t object which contains all the necessary parameters for pool retirement.

Usage Example:

cardano_pool_retirement_cert_t* retirement_cert = ...;  // Assume retirement_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_pool_retirement(retirement_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for pool retirement purposes
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create pool retirement certificate: %s\n", cardano_error_to_string(result));
}

cardano_pool_retirement_cert_unref(&retirement_cert); // Cleanup the retirement_cert

Parameters:
cardano_pool_retirement_cert_t *pool_retirement

[in] A pointer to an initialized cardano_pool_retirement_cert_t object that defines the staking pool’s retirement details.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_register_drep(cardano_register_drep_cert_t *register_drep, cardano_certificate_t **certificate)

Creates a new Cardano certificate for registering a decentralized representation (drep).

This function allocates and initializes a cardano_certificate_t object for registering a drep, using the provided cardano_register_drep_cert_t object which contains all necessary details for the registration.

Usage Example:

cardano_register_drep_cert_t* drep_cert = ...;  // Assume drep_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_register_drep(drep_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for registering the drep
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create register drep certificate: %s\n", cardano_error_to_string(result));
}

cardano_register_drep_cert_unref(&drep_cert); // Cleanup the drep_cert

Parameters:
cardano_register_drep_cert_t *register_drep

[in] A pointer to an initialized cardano_register_drep_cert_t object that defines the details of the drep to be registered.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_registration(cardano_registration_cert_t *registration, cardano_certificate_t **certificate)

Creates a new Cardano certificate for registration.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_registration_cert_t object, which contains the registration details.

Usage Example:

cardano_registration_cert_t* registration_cert = ...;  // Assume registration_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_registration(registration_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for the intended registration purpose
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create registration certificate: %s\n", cardano_error_to_string(result));
}

cardano_registration_cert_unref(&registration_cert); // Cleanup the registration_cert

Parameters:
cardano_registration_cert_t *registration

[in] A pointer to an initialized cardano_registration_cert_t object that specifies the registration details.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_resign_committee_cold(cardano_resign_committee_cold_cert_t *resign_committee_cold, cardano_certificate_t **certificate)

Creates a new Cardano certificate for resigning a committee’s cold key.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_resign_committee_cold_cert_t object, which contains the details for resigning a committee’s cold key.

Usage Example:

cardano_resign_committee_cold_cert_t* resign_cert = ...;  // Assume resign_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_resign_committee_cold(resign_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for committee cold key resignation
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create resignation certificate: %s\n", cardano_error_to_string(result));
}

cardano_resign_committee_cold_cert_unref(&resign_cert); // Cleanup the resign_cert

Parameters:
cardano_resign_committee_cold_cert_t *resign_committee_cold

[in] A pointer to an initialized cardano_resign_committee_cold_cert_t object that specifies the details for the resignation of the committee’s cold key.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_stake_delegation(cardano_stake_delegation_cert_t *stake_delegation, cardano_certificate_t **certificate)

Creates a new Cardano certificate for stake delegation.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_stake_delegation_cert_t object, which contains the details necessary for delegating stake in the Cardano network.

Usage Example:

cardano_stake_delegation_cert_t* delegation_cert = ...;  // Assume delegation_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_stake_delegation(delegation_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for stake delegation purposes
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create stake delegation certificate: %s\n", cardano_error_to_string(result));
}

cardano_stake_delegation_cert_unref(&delegation_cert); // Cleanup the delegation_cert

Parameters:
cardano_stake_delegation_cert_t *stake_delegation

[in] A pointer to an initialized cardano_stake_delegation_cert_t object that specifies the delegation details, including the delegator’s stake key and the target stake pool.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_stake_deregistration(cardano_stake_deregistration_cert_t *stake_deregistration, cardano_certificate_t **certificate)

Creates a new Cardano certificate for stake deregistration.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_stake_deregistration_cert_t object.

Usage Example:

cardano_stake_deregistration_cert_t* deregistration_cert = ...;  // Assume deregistration_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_stake_deregistration(deregistration_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for stake deregistration purposes
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create stake deregistration certificate: %s\n", cardano_error_to_string(result));
}

cardano_stake_deregistration_cert_unref(&deregistration_cert); // Cleanup the deregistration_cert

Parameters:
cardano_stake_deregistration_cert_t *stake_deregistration

[in] A pointer to an initialized cardano_stake_deregistration_cert_t object that specifies the stake key to be deregistered.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_stake_registration(cardano_stake_registration_cert_t *stake_registration, cardano_certificate_t **certificate)

Creates a new Cardano certificate for stake registration.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_stake_registration_cert_t object.

Usage Example:

cardano_stake_registration_cert_t* registration_cert = ...;  // Assume registration_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_stake_registration(registration_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for stake registration purposes
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create stake registration certificate: %s\n", cardano_error_to_string(result));
}

cardano_stake_registration_cert_unref(&registration_cert); // Cleanup the registration_cert

Parameters:
cardano_stake_registration_cert_t *stake_registration

[in] A pointer to an initialized cardano_stake_registration_cert_t object that specifies the stake key to be registered.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_stake_registration_delegation(cardano_stake_registration_delegation_cert_t *stake_registration_delegation, cardano_certificate_t **certificate)

Creates a new Cardano certificate for stake registration with delegation.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_stake_registration_delegation_cert_t object.

Usage Example:

cardano_stake_registration_delegation_cert_t* reg_del_cert = ...;  // Assume reg_del_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_stake_registration_delegation(reg_del_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for stake registration and delegation purposes
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create stake registration and delegation certificate: %s\n", cardano_error_to_string(result));
}

cardano_stake_registration_delegation_cert_unref(&reg_del_cert); // Cleanup the reg_del_cert

Parameters:
cardano_stake_registration_delegation_cert_t *stake_registration_delegation

[in] A pointer to an initialized cardano_stake_registration_delegation_cert_t object that specifies the stake key to be registered and the pool to which it will be delegated.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_stake_vote_delegation(cardano_stake_vote_delegation_cert_t *stake_vote_delegation, cardano_certificate_t **certificate)

Creates a new Cardano certificate for stake vote delegation.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_stake_vote_delegation_cert_t object.

Usage Example:

cardano_stake_vote_delegation_cert_t* vote_del_cert = ...;  // Assume vote_del_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_stake_vote_delegation(vote_del_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for delegating voting rights
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create stake vote delegation certificate: %s\n", cardano_error_to_string(result));
}

cardano_stake_vote_delegation_cert_unref(&vote_del_cert); // Cleanup the vote_del_cert

Parameters:
cardano_stake_vote_delegation_cert_t *stake_vote_delegation

[in] A pointer to an initialized cardano_stake_vote_delegation_cert_t object that specifies the stake key and the party to whom the voting rights are delegated.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_stake_vote_registration_delegation(cardano_stake_vote_registration_delegation_cert_t *stake_vote_registration_delegation, cardano_certificate_t **certificate)

Creates a new Cardano certificate for stake vote registration delegation.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_stake_vote_registration_delegation_cert_t object.

Usage Example:

cardano_stake_vote_registration_delegation_cert_t* reg_del_cert = ...;  // Assume reg_del_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_stake_vote_registration_delegation(reg_del_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for registering and delegating voting rights
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create stake vote registration delegation certificate: %s\n", cardano_error_to_string(result));
}

cardano_stake_vote_registration_delegation_cert_unref(&reg_del_cert); // Cleanup the reg_del_cert

Parameters:
cardano_stake_vote_registration_delegation_cert_t *stake_vote_registration_delegation

[in] A pointer to an initialized cardano_stake_vote_registration_delegation_cert_t object that specifies the stake key and the details necessary for registering and delegating the voting rights.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_unregister_drep(cardano_unregister_drep_cert_t *unregister_drep, cardano_certificate_t **certificate)

Creates a new Cardano certificate for unregistering a DRep.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_unregister_drep_cert_t object.

Usage Example:

cardano_unregister_drep_cert_t* unregister_drep_cert = ...;  // Assume unregister_drep_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_unregister_drep(unregister_drep_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for unregistering the DRep
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create unregister DRep certificate: %s\n", cardano_error_to_string(result));
}

cardano_unregister_drep_cert_unref(&unregister_drep_cert); // Cleanup the unregister_drep_cert

Parameters:
cardano_unregister_drep_cert_t *unregister_drep

[in] A pointer to an initialized cardano_unregister_drep_cert_t object that specifies the details necessary for unregistering the DRep.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_unregistration(cardano_unregistration_cert_t *unregistration, cardano_certificate_t **certificate)

Creates a new Cardano certificate for unregistration.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_unregistration_cert_t object.

Usage Example:

cardano_unregistration_cert_t* unregistration_cert = ...;  // Assume unregistration_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_unregistration(unregistration_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for unregistration purposes
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create unregistration certificate: %s\n", cardano_error_to_string(result));
}

cardano_unregistration_cert_unref(&unregistration_cert); // Cleanup the unregistration_cert

Parameters:
cardano_unregistration_cert_t *unregistration

[in] A pointer to an initialized cardano_unregistration_cert_t object that specifies the details necessary for the unregistration process.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_update_drep(cardano_update_drep_cert_t *update_drep, cardano_certificate_t **certificate)

Creates a new Cardano certificate for updating a delegation representation (Drep).

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_update_drep_cert_t object.

Usage Example:

cardano_update_drep_cert_t* update_drep_cert = ...;  // Assume update_drep_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_update_drep(update_drep_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for updating delegation representation
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create update Drep certificate: %s\n", cardano_error_to_string(result));
}

cardano_update_drep_cert_unref(&update_drep_cert); // Cleanup the update_drep_cert

Parameters:
cardano_update_drep_cert_t *update_drep

[in] A pointer to an initialized cardano_update_drep_cert_t object that specifies the details necessary for the update process.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_vote_delegation(cardano_vote_delegation_cert_t *vote_delegation, cardano_certificate_t **certificate)

Creates a new Cardano certificate for vote delegation.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_vote_delegation_cert_t object.

Usage Example:

cardano_vote_delegation_cert_t* vote_delegation_cert = ...;  // Assume vote_delegation_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_vote_delegation(vote_delegation_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for voting delegation purposes
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create vote delegation certificate: %s\n", cardano_error_to_string(result));
}

cardano_vote_delegation_cert_unref(&vote_delegation_cert); // Cleanup the vote_delegation_cert

Parameters:
cardano_vote_delegation_cert_t *vote_delegation

[in] A pointer to an initialized cardano_vote_delegation_cert_t object that specifies the details necessary for the delegation of voting rights.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_new_vote_registration_delegation(cardano_vote_registration_delegation_cert_t *vote_registration_delegation, cardano_certificate_t **certificate)

Creates a new Cardano certificate for vote registration and delegation.

This function allocates and initializes a cardano_certificate_t object based on the provided cardano_vote_registration_delegation_cert_t object.

Usage Example:

cardano_vote_registration_delegation_cert_t* vote_reg_del_cert = ...;  // Assume vote_reg_del_cert is already initialized
cardano_certificate_t* certificate = NULL;
cardano_error_t result = cardano_certificate_new_vote_registration_delegation(vote_reg_del_cert, &certificate);

if (result == CARDANO_SUCCESS)
{
  // The certificate can now be used for both registration and delegation of voting rights
  // Remember to free the certificate when done
  cardano_certificate_unref(&certificate);
}
else
{
  printf("Failed to create vote registration and delegation certificate: %s\n", cardano_error_to_string(result));
}

cardano_vote_registration_delegation_cert_unref(&vote_reg_del_cert); // Cleanup the vote_reg_del_cert

Parameters:
cardano_vote_registration_delegation_cert_t *vote_registration_delegation

[in] A pointer to an initialized cardano_vote_registration_delegation_cert_t object that specifies the details necessary for the registration and delegation of voting rights.

cardano_certificate_t **certificate

[out] On successful execution, this will point to a newly created cardano_certificate_t object. The caller is responsible for releasing this resource using cardano_certificate_unref when it is no longer needed.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificate was successfully created, or an error code indicating the reason for failure (e.g., CARDANO_ERROR_POINTER_IS_NULL if any input pointers are NULL).


cardano_error_t cardano_certificate_from_cbor(cardano_cbor_reader_t *reader, cardano_certificate_t **auth_committee_hot)

Creates a cardano_certificate_t from a CBOR reader.

This function parses CBOR data using a provided cardano_cbor_reader_t and constructs a cardano_certificate_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_certificate_t* auth_committee_hot = NULL;

cardano_error_t result = cardano_certificate_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_certificate_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_certificate_t object by calling cardano_certificate_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_certificate_t **auth_committee_hot

[out] A pointer to a pointer of cardano_certificate_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_certificate_to_cbor(const cardano_certificate_t *auth_committee_hot, cardano_cbor_writer_t *writer)

Serializes the certificate into CBOR format using a CBOR writer.

This function serializes the given cardano_certificate_t object using a cardano_cbor_writer_t.

Usage Example:

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

if (writer)
{
  cardano_error_t result = cardano_certificate_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_certificate_unref(&auth_committee_hot);

Parameters:
const cardano_certificate_t *auth_committee_hot

[in] A constant pointer to the cardano_certificate_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_certificate_to_cip116_json(const cardano_certificate_t *certificate, cardano_json_writer_t *writer)

Serializes a certificate to CIP-116 JSON.

This function acts as a dispatcher, identifying the specific type of the certificate and calling the appropriate serialization function.

Parameters:
const cardano_certificate_t *certificate

[in] Pointer to a valid cardano_certificate_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 certificate or writer is NULL. CARDANO_ERROR_INVALID_CERTIFICATE_TYPE If the certificate type is unknown or unsupported. Other Any error propagated from nested writers.


cardano_error_t cardano_cert_get_type(const cardano_certificate_t *certificate, cardano_cert_type_t *type)

Retrieves the type of a Cardano certificate.

This function determines the type of a given cardano_certificate_t object, which indicates the specific kind of operations or permissions the certificate represents within the Cardano blockchain ecosystem.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_cert_type_t type;

cardano_error_t result = cardano_cert_get_type(certificate, &type);
if (result == CARDANO_SUCCESS)
{
  printf("Certificate type: %d\n", type);
}
else
{
  printf("Failed to retrieve certificate type.\n");
}

Parameters:
const cardano_certificate_t *certificate

[in] A constant pointer to an initialized cardano_certificate_t object whose type is to be determined.

cardano_cert_type_t *type

[out] A pointer to a cardano_cert_type_t variable where the type of the certificate will be stored upon successful execution.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the type was successfully retrieved, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if either input pointer is NULL.


cardano_error_t cardano_certificate_to_auth_committee_hot(cardano_certificate_t *certificate, cardano_auth_committee_hot_cert_t **auth_committee_hot_cert)

Converts a certificate to an authorization committee hot certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_auth_committee_hot_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_auth_committee_hot_cert_t* auth_committee_hot_cert = NULL;

cardano_error_t result = cardano_certificate_to_auth_committee_hot(certificate, &auth_committee_hot_cert);
if (result == CARDANO_SUCCESS && auth_committee_hot_cert != NULL)
{
  // Successfully converted certificate to auth committee hot certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, auth_committee_hot_cert will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_auth_committee_hot_cert_t **auth_committee_hot_cert

[out] On successful conversion, this will point to the cardano_auth_committee_hot_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_genesis_key_delegation(cardano_certificate_t *certificate, cardano_genesis_key_delegation_cert_t **genesis_key_delegation)

Converts a certificate to a genesis key delegation certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_genesis_key_delegation_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_genesis_key_delegation_cert_t* genesis_key_delegation = NULL;

cardano_error_t result = cardano_certificate_to_genesis_key_delegation(certificate, &genesis_key_delegation);
if (result == CARDANO_SUCCESS && genesis_key_delegation != NULL)
{
  // Successfully converted certificate to genesis key delegation certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, genesis_key_delegation will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_genesis_key_delegation_cert_t **genesis_key_delegation

[out] On successful conversion, this will point to the cardano_genesis_key_delegation_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_mir(cardano_certificate_t *certificate, cardano_mir_cert_t **mir)

Converts a certificate to an MIR certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_mir_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_mir_cert_t* mir = NULL;

cardano_error_t result = cardano_certificate_to_mir(certificate, &mir);
if (result == CARDANO_SUCCESS && mir != NULL)
{
  // Successfully converted certificate to MIR certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, mir will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_mir_cert_t **mir

[out] On successful conversion, this will point to the cardano_mir_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_pool_registration(cardano_certificate_t *certificate, cardano_pool_registration_cert_t **pool_registration)

Converts a certificate to a pool registration certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_pool_registration_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_pool_registration_cert_t* pool_registration = NULL;

cardano_error_t result = cardano_certificate_to_pool_registration(certificate, &pool_registration);
if (result == CARDANO_SUCCESS && pool_registration != NULL)
{
  // Successfully converted certificate to pool registration certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, pool_registration will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_pool_registration_cert_t **pool_registration

[out] On successful conversion, this will point to the cardano_pool_registration_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_pool_retirement(cardano_certificate_t *certificate, cardano_pool_retirement_cert_t **pool_retirement)

Converts a certificate to a pool retirement certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_pool_retirement_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_pool_retirement_cert_t* pool_retirement = NULL;

cardano_error_t result = cardano_certificate_to_pool_retirement(certificate, &pool_retirement);
if (result == CARDANO_SUCCESS && pool_retirement != NULL)
{
  // Successfully converted certificate to pool retirement certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, pool_retirement will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_pool_retirement_cert_t **pool_retirement

[out] On successful conversion, this will point to the cardano_pool_retirement_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_register_drep(cardano_certificate_t *certificate, cardano_register_drep_cert_t **register_drep)

Converts a certificate to a register drep certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_register_drep_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_register_drep_cert_t* register_drep = NULL;

cardano_error_t result = cardano_certificate_to_register_drep(certificate, &register_drep);
if (result == CARDANO_SUCCESS && register_drep != NULL)
{
  // Successfully converted certificate to register drep certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, register_drep will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_register_drep_cert_t **register_drep

[out] On successful conversion, this will point to the cardano_register_drep_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_registration(cardano_certificate_t *certificate, cardano_registration_cert_t **registration)

Converts a certificate to a registration certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_registration_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_registration_cert_t* registration = NULL;

cardano_error_t result = cardano_certificate_to_registration(certificate, &registration);
if (result == CARDANO_SUCCESS && registration != NULL)
{
  // Successfully converted certificate to registration certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, registration will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_registration_cert_t **registration

[out] On successful conversion, this will point to the cardano_registration_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_resign_committee_cold(cardano_certificate_t *certificate, cardano_resign_committee_cold_cert_t **resign_committee_cold)

Converts a certificate to a resign committee cold certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_resign_committee_cold_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_resign_committee_cold_cert_t* resign_committee_cold = NULL;

cardano_error_t result = cardano_certificate_to_resign_committee_cold(certificate, &resign_committee_cold);
if (result == CARDANO_SUCCESS && resign_committee_cold != NULL)
{
  // Successfully converted certificate to resign committee cold certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, resign_committee_cold will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_resign_committee_cold_cert_t **resign_committee_cold

[out] On successful conversion, this will point to the cardano_resign_committee_cold_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_stake_delegation(cardano_certificate_t *certificate, cardano_stake_delegation_cert_t **stake_delegation)

Converts a certificate to a stake delegation certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_stake_delegation_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_stake_delegation_cert_t* stake_delegation = NULL;

cardano_error_t result = cardano_certificate_to_stake_delegation(certificate, &stake_delegation);
if (result == CARDANO_SUCCESS && stake_delegation != NULL)
{
  // Successfully converted certificate to stake delegation certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, stake_delegation will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_stake_delegation_cert_t **stake_delegation

[out] On successful conversion, this will point to the cardano_stake_delegation_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_stake_deregistration(cardano_certificate_t *certificate, cardano_stake_deregistration_cert_t **stake_deregistration)

Converts a certificate to a stake deregistration certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_stake_deregistration_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_stake_deregistration_cert_t* stake_deregistration = NULL;

cardano_error_t result = cardano_certificate_to_stake_deregistration(certificate, &stake_deregistration);
if (result == CARDANO_SUCCESS && stake_deregistration != NULL)
{
  // Successfully converted certificate to stake deregistration certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, stake_deregistration will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_stake_deregistration_cert_t **stake_deregistration

[out] On successful conversion, this will point to the cardano_stake_deregistration_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_stake_registration(cardano_certificate_t *certificate, cardano_stake_registration_cert_t **stake_registration)

Converts a certificate to a stake registration certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_stake_registration_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_stake_registration_cert_t* stake_registration = NULL;

cardano_error_t result = cardano_certificate_to_stake_registration(certificate, &stake_registration);
if (result == CARDANO_SUCCESS && stake_registration != NULL)
{
  // Successfully converted certificate to stake registration certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, stake_registration will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_stake_registration_cert_t **stake_registration

[out] On successful conversion, this will point to the cardano_stake_registration_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_stake_registration_delegation(cardano_certificate_t *certificate, cardano_stake_registration_delegation_cert_t **stake_registration_delegation)

Converts a certificate to a stake registration delegation certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_stake_registration_delegation_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_stake_registration_delegation_cert_t* stake_registration_delegation = NULL;

cardano_error_t result = cardano_certificate_to_stake_registration_delegation(certificate, &stake_registration_delegation);
if (result == CARDANO_SUCCESS && stake_registration_delegation != NULL)
{
  // Successfully converted certificate to stake registration delegation certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, stake_registration_delegation will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_stake_registration_delegation_cert_t **stake_registration_delegation

[out] On successful conversion, this will point to the cardano_stake_registration_delegation_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_stake_vote_delegation(cardano_certificate_t *certificate, cardano_stake_vote_delegation_cert_t **stake_vote_delegation)

Converts a certificate to a stake vote delegation certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_stake_vote_delegation_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_stake_vote_delegation_cert_t* stake_vote_delegation = NULL;

cardano_error_t result = cardano_certificate_to_stake_vote_delegation(certificate, &stake_vote_delegation);
if (result == CARDANO_SUCCESS && stake_vote_delegation != NULL)
{
  // Successfully converted certificate to stake vote delegation certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, stake_vote_delegation will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_stake_vote_delegation_cert_t **stake_vote_delegation

[out] On successful conversion, this will point to the cardano_stake_vote_delegation_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_stake_vote_registration_delegation(cardano_certificate_t *certificate, cardano_stake_vote_registration_delegation_cert_t **stake_vote_registration_delegation)

Converts a certificate to a stake vote registration delegation certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_stake_vote_registration_delegation_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_stake_vote_registration_delegation_cert_t* stake_vote_registration_delegation = NULL;

cardano_error_t result = cardano_certificate_to_stake_vote_registration_delegation(certificate, &stake_vote_registration_delegation);
if (result == CARDANO_SUCCESS && stake_vote_registration_delegation != NULL)
{
  // Successfully converted certificate to stake vote registration delegation certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, stake_vote_registration_delegation will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_stake_vote_registration_delegation_cert_t **stake_vote_registration_delegation

[out] On successful conversion, this will point to the cardano_stake_vote_registration_delegation_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_unregister_drep(cardano_certificate_t *certificate, cardano_unregister_drep_cert_t **unregister_drep)

Converts a certificate to an unregister DREP certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_unregister_drep_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_unregister_drep_cert_t* unregister_drep = NULL;

cardano_error_t result = cardano_certificate_to_unregister_drep(certificate, &unregister_drep);
if (result == CARDANO_SUCCESS && unregister_drep != NULL)
{
  // Successfully converted certificate to unregister DREP certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, unregister_drep will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_unregister_drep_cert_t **unregister_drep

[out] On successful conversion, this will point to the cardano_unregister_drep_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_unregistration(cardano_certificate_t *certificate, cardano_unregistration_cert_t **unregistration)

Converts a certificate to an unregistration certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_unregistration_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_unregistration_cert_t* unregistration = NULL;

cardano_error_t result = cardano_certificate_to_unregistration(certificate, &unregistration);
if (result == CARDANO_SUCCESS && unregistration != NULL)
{
  // Successfully converted certificate to unregistration certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, unregistration will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_unregistration_cert_t **unregistration

[out] On successful conversion, this will point to the cardano_unregistration_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_update_drep(cardano_certificate_t *certificate, cardano_update_drep_cert_t **update_drep)

Converts a certificate to an update drep certificate type.

This function attempts to convert a cardano_certificate_t object into a cardano_update_drep_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_update_drep_cert_t* update_drep = NULL;

cardano_error_t result = cardano_certificate_to_update_drep(certificate, &update_drep);
if (result == CARDANO_SUCCESS && update_drep != NULL)
{
  // Successfully converted certificate to update drep certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, update_drep will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_update_drep_cert_t **update_drep

[out] On successful conversion, this will point to the cardano_update_drep_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_vote_delegation(cardano_certificate_t *certificate, cardano_vote_delegation_cert_t **vote_delegation)

Converts a certificate to a vote delegation certificate.

This function attempts to convert a cardano_certificate_t object into a cardano_vote_delegation_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_vote_delegation_cert_t* vote_delegation = NULL;

cardano_error_t result = cardano_certificate_to_vote_delegation(certificate, &vote_delegation);
if (result == CARDANO_SUCCESS && vote_delegation != NULL)
{
  // Successfully converted certificate to vote delegation certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, vote_delegation will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_vote_delegation_cert_t **vote_delegation

[out] On successful conversion, this will point to the cardano_vote_delegation_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


cardano_error_t cardano_certificate_to_vote_registration_delegation(cardano_certificate_t *certificate, cardano_vote_registration_delegation_cert_t **vote_registration_delegation)

Converts a certificate to a vote registration delegation certificate.

This function attempts to convert a cardano_certificate_t object into a cardano_vote_registration_delegation_cert_t object.

Usage Example:

cardano_certificate_t* certificate = ...; // Assume certificate is already initialized
cardano_vote_registration_delegation_cert_t* vote_registration_delegation = NULL;

cardano_error_t result = cardano_certificate_to_vote_registration_delegation(certificate, &vote_registration_delegation);
if (result == CARDANO_SUCCESS && vote_registration_delegation != NULL)
{
  // Successfully converted certificate to vote registration delegation certificate
}
else
{
  // Handle failure or incorrect certificate type
}

Note

If the conversion fails or the certificate type is incorrect, vote_registration_delegation will be set to NULL.

Parameters:
cardano_certificate_t *certificate

[in] A pointer to an initialized cardano_certificate_t object.

cardano_vote_registration_delegation_cert_t **vote_registration_delegation

[out] On successful conversion, this will point to the cardano_vote_registration_delegation_cert_t object derived from the certificate. If the certificate is not of the correct type, this will be set to NULL.

Returns:

cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the conversion was successful, or an appropriate error code indicating the failure reason. If the certificate type does not match, the function will return CARDANO_ERROR_INVALID_CERTIFICATE_TYPE.


void cardano_certificate_unref(cardano_certificate_t **auth_committee_hot)

Decrements the reference count of a cardano_certificate_t object.

This function is responsible for managing the lifecycle of a cardano_certificate_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_certificate_t* auth_committee_hot = cardano_certificate_new(major, minor);

// Perform operations with the auth_committee_hot...

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

Note

After calling cardano_certificate_unref, the pointer to the cardano_certificate_t object will be set to NULL to prevent its reuse.

Parameters:
cardano_certificate_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_certificate_ref(cardano_certificate_t *auth_committee_hot)

Increases the reference count of the cardano_certificate_t object.

This function is used to manually increment the reference count of an cardano_certificate_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_certificate_unref.

Usage Example:

// Assuming auth_committee_hot is a previously created auth_committee_hot object

cardano_certificate_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_certificate_ref there is a corresponding call to cardano_certificate_unref to prevent memory leaks.

Parameters:
cardano_certificate_t *auth_committee_hot

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


size_t cardano_certificate_refcount(const cardano_certificate_t *auth_committee_hot)

Retrieves the current reference count of the cardano_certificate_t object.

This function returns the number of active references to an cardano_certificate_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_certificate_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_certificate_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_certificate_t *auth_committee_hot

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

Returns:

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


void cardano_certificate_set_last_error(cardano_certificate_t *auth_committee_hot, const char *message)

Sets the last error message for a given cardano_certificate_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_certificate_t *auth_committee_hot

[in] A pointer to the cardano_certificate_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_certificate_get_last_error(const cardano_certificate_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_certificate_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_certificate_set_last_error for the same auth_committee_hot, or until the auth_committee_hot is deallocated.

Parameters:
const cardano_certificate_t *auth_committee_hot

[in] A pointer to the cardano_certificate_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.