assist/count

This module contains code to accurately count the number of inputs and outputs in a transaction containing an address or a datum.

Functions

inputs_by_addr(inputs: List<Input>, addr: Address, amount: Int) -> Bool

Verify that the number of inputs from a specific script is equal to the amount intended in the contract. The amount must be exactly the counter.

count.inputs_by_addr(tx.inputs, this_addr, 1)

inputs_by_datum(inputs: List<Input>, amount: Int) -> Bool

Verify that the number of inputs with an inline datum or datum hash is equal to the number intended in the contract. The amount must be exactly the counter.

count.inputs_by_datum(tx.inputs, 1)

inputs_by_vkh(inputs: List<Input>, amount: Int) -> Bool

Count the number of inputs with a payment credential that is a script. This does not take in an address but is a general count of validator hashes.

count.inputs_by_vkh(tx.inputs, 1)

outputs_by_addr(outputs: List<Output>, addr: Address, amount: Int) -> Bool

Verify that the number of outputs from a specific script is equal the amount intended in the contract. The amount must be exact with the counter.

count.outputs_by_addr(tx.outputs, this_addr, 1)

outputs_by_datum(outputs: List<Output>, amount: Int) -> Bool

Verify that the number of outputs with an inline datum or datum hash is equal to the number intended in the contract. The amount must be exactly the counter.

count.outputs_by_datum(tx.outputs, 1)

outputs_by_vkh(outputs: List<Output>, amount: Int) -> Bool

Count the number of outputs with a payment credential that is a script. This does not take in an address but is a general count of validator hashes.

count.outputs_by_vkh(tx.outputs, 1)

single_input_with_bypass(
  inputs: List<Input>,
  this_addr: Address,
  those_addrs: List<Address>,
) -> Bool

The contract can only be spent by itself or along side some list of know addresses. Loop all the inputs and count how many datums belong to this address. If any of those addresses exists then pass right over them but if anything else is found then fail. This should prevent unregulated contracts from being spent along side this script.

count.single_input_with_bypass(this_tx.inputs, this_addr, [that_addr])
Search Document