validation/find
This module contains code for finding various aspects of a validating transaction.
Functions
Find the first input’s output reference index.
Output references have the form TxId#Idx
, this function
extracts the Idx
part. If nothing is found then error.
find.first_input_index(tx.inputs)
Find the first input’s output reference transaction id hash.
Output references have the form TxId#Idx
, this function
extracts the TxId
part. If nothing is found then error.
find.first_input_txid(tx.inputs)
Find an input by an output reference. If nothing is found then error.
Similar to the builtin function in stdlib but auto errors instead of
returning an Option
.
find.input_by_ref(tx.inputs, out_ref)
Find the first occurrence of an input by a specific address. If nothing is found then error. The address here is an exact match, so both the pkh and sc need to be correct.
find.input_by_addr(tx.reference_inputs, ref_addr)
Find the first occurrence of an output by a specific address. If nothing is found then error. The address here is an exact match.
find.output_by_addr(tx.outputs, your_address)
Find the first output with an inline datum and return the datum. If nothing is found then error. This works great for tx with a single output and datum or where ordering is irrelevant.
find.first_output_datum(tx.outputs)
Find the first occurence of output datum by some address. If nothing is found then error.
expect datum: Datum = find.output_datum_by_addr(tx.outputs, this_addr)
Return the first occurrence of an output that contains at least some specific value at some address. If nothing is found then error. This function does not search for an exact UTxO match.
find.output_by_addr_value(tx.outputs, wallet_addr, just_token_value)
Return the first occurrence of an output that contains at least some specific value. If nothing is found then error. This function does not search for an exact UTxO match.
find.output_by_value(tx.outputs, just_token_value)
Find the staking reward amount in loveace for some stake credential. If no rewards are available then error. This is a great method for checking on-chain staking rewards and withdrawal validation.
find.stake_reward_by_sc(tx.withdrawals, datum.wallet.sc)
Find a redeemer data by an output reference. This is good for checking if a specific redeemer is being used on some specific UTxO inside the transaction.
find.redeemer_by_ref(tx.redeemers, that_out_ref)
Find the first occurance of an inline datum on an output with a value that contains a specific nft.