Redeemer

class cometa.witness_set.redeemer.Redeemer(ptr)[source]

Bases: object

The Redeemer is an argument provided to a Plutus smart contract (script) when you are attempting to redeem a UTxO that’s protected by that script.

A redeemer includes a tag (indicating the type of action), an index, data (the actual argument to the script), and execution units (computational cost required for script execution).

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

Redeemer

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

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod new(tag, index, data, ex_units)[source]

Creates a new redeemer.

Parameters:
  • tag (RedeemerTag) – The type of action (spending, minting, etc.) this redeemer is for.

  • index (int) – The index of the transaction input this redeemer is intended for.

  • data (PlutusData) – The Plutus data to pass to the script.

  • ex_units (ExUnits) – The execution units allocated for this redeemer.

Returns:

A new Redeemer instance.

Raises:

CardanoError – If creation fails.

Return type:

Redeemer

classmethod from_cbor(reader)[source]

Deserializes a Redeemer from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the redeemer data.

Returns:

A new Redeemer deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

Redeemer

to_cbor(writer)[source]

Serializes the redeemer to CBOR format.

Parameters:

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

Raises:

CardanoError – If serialization fails.

Return type:

None

property tag: RedeemerTag

The tag indicating the type of action this redeemer is for.

Returns:

The RedeemerTag value.

property index: int

The index of the transaction input this redeemer applies to.

Returns:

The index value.

property data: PlutusData

The Plutus data associated with this redeemer.

Returns:

The PlutusData object.

property ex_units: ExUnits

The execution units allocated for this redeemer.

Returns:

The ExUnits object.

clear_cbor_cache()[source]

Clears the cached CBOR representation.

This is useful when you have modified the redeemer after it was created from CBOR and you want to ensure that the next serialization reflects the current state rather than using the original cached CBOR.

Warning

Clearing the CBOR cache may change the binary representation when serialized, which can invalidate existing signatures.

Return type:

None

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