ScriptDataHash
- cometa.transaction_builder.script_data_hash.compute_script_data_hash(costmdls, redeemers, datums=None)[source]
Compute the hash of script data in a transaction.
This function processes redeemers, datums, and cost models to compute a 32-byte hash that represents the script data for a transaction. The data is encoded in CBOR format and hashed using the Blake2b hashing algorithm.
The script data hash is required in the transaction body when the transaction includes Plutus scripts.
- Parameters:
costmdls (Costmdls) – The cost models for script execution.
redeemers (RedeemerList) – The transaction’s redeemers.
datums (Optional['PlutusDataSet']) – Optional set of datums included in the transaction.
- Returns:
The computed 32-byte Blake2b hash for the script data.
- Raises:
CardanoError – If hash computation fails.
- Return type:
Example
>>> from cometa.transaction_builder import compute_script_data_hash >>> from cometa.protocol_params import Costmdls >>> from cometa.witness_set import RedeemerList >>> >>> costmdls = Costmdls.new() >>> redeemers = RedeemerList.new() >>> # ... populate costmdls and redeemers ... >>> script_hash = compute_script_data_hash(costmdls, redeemers) >>> print(script_hash.to_hex())