ExUnitPrices

class cometa.protocol_params.ex_unit_prices.ExUnitPrices(ptr)[source]

Bases: object

Specifies the cost (in Lovelace) of execution units.

Execution unit prices set the “price” for the computational resources used by smart contracts. They are expressed as unit intervals representing the cost per unit of memory and CPU steps.

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

ExUnitPrices

__exit__(exc_type, exc_val, exc_tb)[source]
Return type:

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod new(memory_prices, steps_prices)[source]

Creates a new ExUnitPrices instance.

Parameters:
  • memory_prices (UnitInterval) – The price per unit of memory consumption.

  • steps_prices (UnitInterval) – The price per CPU step.

Returns:

A new ExUnitPrices instance.

Raises:

CardanoError – If creation fails.

Return type:

ExUnitPrices

Example

>>> mem = UnitInterval.new(577, 10000)
>>> cpu = UnitInterval.new(721, 10000000)
>>> prices = ExUnitPrices.new(mem, cpu)
classmethod from_cbor(reader)[source]

Deserializes ExUnitPrices from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the ex unit prices data.

Returns:

A new ExUnitPrices deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

ExUnitPrices

to_cbor(writer)[source]

Serializes the ex unit prices to CBOR format.

Parameters:

writer (CborWriter) – A CborWriter to write the serialized data to.

Raises:

CardanoError – If serialization fails.

Return type:

None

property memory_prices: UnitInterval

Returns the price for memory consumption.

Returns:

A UnitInterval representing the memory price.

property steps_prices: UnitInterval

Returns the price for CPU steps.

Returns:

A UnitInterval representing the CPU steps price.

to_cip116_json(writer)[source]

Serializes this object to CIP-116 compliant JSON.

Parameters:

writer (JsonWriter) – The JsonWriter to write the JSON to.

Raises:

CardanoError – If serialization fails.

Return type:

None