cardano/tx

This module incorporates additional code that expands the functionality of the standard library.

To check for a single signature, use stdlib’s list.has(tx.extra_signatories, vkh).

Functions

output_reference(tx_id_hash: ByteArray, idx: Int) -> OutputReference

Create an OutputReference from the TxId#Idx information. This is useful for building correct output references of specific UTxOs. It can be combined with the find module for some very convenient requests.

tx.output_reference(that_tx_id, that_tx_idx)

verify_multisig(
  sigs: List<VerificationKeyHash>,
  vks: List<VerificationKeyHash>,
  minimum: Int,
) -> Bool

This counts how many of the verification keys in vks have signed the transaction, then checks that the count is at least minimum.

Each element of vks is counted separately, so a key listed twice counts twice. If vks can be influenced by a user, deduplicate it first (e.g. list.unique). A minimum of zero or less is always satisfied.

tx.verify_multisig(tx.extra_signatories, datum.signers, datum.threshold)

is_spending_input(inputs: List<Input>, out_ref: OutputReference) -> Bool

Check if a specific input by output reference is being spent. This is useful when a minting script requires a utxo to be spent but doesn’t need any specific information about that input. Returns True or fails.

tx.is_spending_input(tx.inputs, output_reference)

not_being_spent_from(
  validator_hashes: List<ScriptHash>,
  inputs: List<Input>,
) -> Bool

Given a set of validator hashes prove that none of them are being spent. An input counts as being spent from a validator when its payment credential is that script, regardless of its stake credential.

tx.not_being_spent_from(not_these_vkhs, tx.inputs)

total_token_amount(
  inputs: List<Input>,
  pid: PolicyId,
  tkn: AssetName,
  threshold: Int,
) -> Bool

Calculate the total amount of a token within the set of inputs for the transaction and check if it is at least equal to the provided threshold.

tx.total_token_amount(tx.inputs, datum.pid, datum.tkn, datum.threshold)
Search Document