is it possible for a Validator to ensure that the redeemer pays some Value along with a certain Datum attached to it? Looking at the possible transaction methods on the ScriptContext, checks are only done on the Value and not the Datum. I see the DatumHash types but am not sure what it is used for.
1 Answer
The validator can ensure that a datum or multiple datums are included in the output.
Take the Uniswap clone in the plutus-use-cases for example:
The validateCreate
method ensures that an updated Factory
datum
Constraints.checkOwnOutputConstraint ctx (OutputConstraint (Factory $ lp : lps) $ unitValue usCoin)
and a new Pool
datum
Constraints.checkOwnOutputConstraint ctx (OutputConstraint (Pool lp liquidity) $ valueOf lpCoinA outA <> valueOf lpCoinB outB <> unitValue c)
are included in the outputs.
Both of these are attached to some Value
.
-
1Oh gosh I didn't know there was a whole library on On-Chain Constraints. Thank you! As for the term Redeemer, I believe the language used has been not-strict enough. So to my understanding, the person initiating the transaction is called the Redeemer, and he/she will supply a RedeemerType to the Validator to spend the underlying eUTXO. Link to the On-Chain constraints library: [github.com/input-output-hk/plutus/blob/… Commented Jul 22, 2021 at 6:07
-
1Yeah. The on-chain constraints are great and they compliment the off-chain constraints well. The more declarative the better :) Commented Jul 22, 2021 at 6:40