Script Utility Functions

cometa.aiken.apply_params_to_script(params, compiled_code)[source]

Apply parameters to a parameterized Plutus script.

This function takes a list of Plutus data parameters and a compiled script (in hex format), and returns the script with parameters applied.

Parameters:
  • params (Union['PlutusList', List['PlutusData']]) – A PlutusList or list of PlutusData representing the parameters to apply to the script.

  • compiled_code (str) – The compiled script code in hex format (from blueprint).

Returns:

The compiled code with parameters applied, in hex format.

Raises:

ApplyParamsError – If applying parameters fails.

Return type:

str

Example

>>> from cometa.aiken import apply_params_to_script
>>> from cometa.plutus_data import PlutusList, PlutusData
>>>
>>> # Create parameters
>>> params = PlutusList()
>>> params.append(PlutusData.from_hex("d87980"))  # Owner pubkey hash
>>> params.append(42)  # Some integer parameter
>>>
>>> # Apply to compiled script from Aiken blueprint
>>> compiled = "..."  # hex from blueprint
>>> result = apply_params_to_script(params, compiled)