ExUnits
- class cometa.common.ex_units.ExUnits(ptr)[source]
Bases:
objectRepresents execution units for Plutus script execution.
Execution units measure the computational resources required to run a Plutus script on the Cardano blockchain. They consist of two components:
Memory: The amount of memory the script is expected to consume
CPU steps: The number of CPU steps the script is expected to require
These values are used to calculate transaction fees and ensure scripts don’t overrun system resources.
Example
>>> ex_units = ExUnits.new(memory=1000000, cpu_steps=500000000) >>> ex_units.memory 1000000
- classmethod new(memory, cpu_steps)[source]
Creates new execution units with the specified memory and CPU steps.
- Parameters:
memory (int) – The amount of memory (in units) for script execution.
cpu_steps (int) – The number of CPU steps for script execution.
- Returns:
A new ExUnits instance.
- Raises:
CardanoError – If creation fails.
- Return type:
Example
>>> ex_units = ExUnits.new(1024, 500)
- classmethod from_cbor(reader)[source]
Deserializes ExUnits from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the execution units data.
- Returns:
A new ExUnits deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- property memory: int
Returns the memory component of the execution units.
- property cpu_steps: int
Returns the CPU steps component of the execution units.
- to_cbor(writer)[source]
Serializes the execution units to CBOR format.
- Parameters:
writer (CborWriter) – A CborWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- to_cip116_json(writer)[source]
Converts this object to CIP-116 compliant JSON representation.
CIP-116 defines a standard JSON format for Cardano data structures.
- Parameters:
writer (JsonWriter) – A JsonWriter to write the serialized data to.
- Raises:
CardanoError – If conversion fails.
- Return type:
None