Applying the functions (1) findOwnInput and (2) getContinuingOutputs in a context both return TxOut. What is the difference between these two TxOut?
2 Answers
getContinuingOutputs
makes use of findOwnInput
to find all outputs at the script address.
findOwnInputs
only returns Maybe TxInInfo
.
See here fore implementation details:
getContinuingOutputs
- findOwnInput get the actual utxo being consumed and validated for that validator in that moment.
- same validator could run more than one time if you are consuming more than one utxo at the smart contract address. Every time findOwnInput will give you different result.
- getContinuingOutputs will give you all the utxo at the outputs that are going to be locked and saved in the contract address after the transaction.
Example:
I create a transaction using Utxo1 and Utxo2 as inputs and with two expected outputs, one utxo3 going again to the contract and another going to some wallet, utxo4
The transaction will execute the contract two times for validate the consume of utxo1 and utxo2.
In the first run of the validator, findOwnInput will give you Utxo1 In the second run will give you Utxo2
In all the runs getContinuingOutputs will give you the output going to the contract, in this case Utxo3