aiken_design_patterns/multi_utxo_indexer

Functions

One-to-One

one_to_one_no_redeemer(
  indices: Pairs<Int, Int>,
  spending_script_hash: ScriptHash,
  inputs: List<Input>,
  outputs: List<Output>,
  validation_logic: fn(Int, Input, Int, Output) -> Bool,
) -> Bool

Helper function for performing spending validation on multiple inputs from a given script, each with a corresponding output. It expects both the input and output indices be in ascending order.

The validation function you should provide has access to:

  • Index of the Input being validated
  • The Input itself
  • Index of the Output being validated
  • The Output itself

one_to_one_with_redeemer(
  indices: Pairs<Int, Int>,
  spending_script_hash: ScriptHash,
  stake_script_hash: ScriptHash,
  inputs: List<Input>,
  outputs: List<Output>,
  redeemers: Pairs<ScriptPurpose, Redeemer>,
  spend_redeemer_coercer_and_stake_credential_extractor: fn(Data) ->
    (a, Credential),
  validation_logic: fn(Int, Input, a, Int, Output) -> Bool,
) -> Bool

Another variant with a staking script (i.e. withdraw-0 script) as a coupling element for spending multiple UTxOs from a given spending script.

Here the redeemers is also traversed to provide the validation logic with the redeemer used for spending each of the UTxOs.

Assumption here is that redeemers carry the staking credential of the withdraw-0 validator, which is the purpose of the additional argument, i.e. coercing the redeemer Data into an expected structure, and extracting the staking credential.

Search Document