Script Data Hash¶
-
cardano_error_t cardano_compute_script_data_hash(cardano_costmdls_t *costmdls, cardano_redeemer_list_t *redeemers, cardano_plutus_data_set_t *datums, cardano_blake2b_hash_t **data_hash)¶
Computes the hash of script data in a transaction, including redeemers, datums, and cost models.
This function processes arrays of redeemers and datums, along with specified cost models, to compute a 32-byte hash that represents the script data for a transaction. The data is encoded in CBOR (Concise Binary Object Representation) format and hashed using the Blake2b hashing algorithm.
Usage Example:
cardano_costmdls_t* costmdls = ...; // Initialized cost models cardano_redeemer_list_t* redeemers = ...; // List of redeemers cardano_plutus_data_set_t* datums = ...; // Set of datums cardano_blake2b_hash_t* data_hash = NULL; cardano_error_t result = cardano_compute_script_data_hash(costmdls, redeemers, datums, &data_hash); if (result == CARDANO_SUCCESS && data_hash != NULL) { // Successfully computed the hash of the script data } else { printf("Failed to compute the script data hash.\n"); } cardano_blake2b_hash_unref(&data_hash);- Parameters:¶
- cardano_costmdls_t *costmdls¶
[in] A pointer to cardano_costmdls_t representing the cost models for script execution.
- cardano_redeemer_list_t *redeemers¶
[in] A pointer to cardano_redeemer_list_t containing the transaction’s redeemers. If this parameter is NULL or empty, the function may return undefined behavior.
- cardano_plutus_data_set_t *datums¶
[in] A pointer to cardano_plutus_data_set_t representing the datums included in the transaction.
- cardano_blake2b_hash_t **data_hash¶
[out] On successful computation, this will point to a cardano_blake2b_hash_t containing the computed 32-byte hash for the script data.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the script data hash was successfully computed, or an appropriate error code if a failure occurred. If no redeemers are provided, the function may return an undefined result.