In gift.hs
, I do not understand the logic for why in the lookups for the grab
contract there is Constraints.otherScript validator
. The grabber is the consumer of the UTXO and thus the burden of providing the validator is on him, not the provider. It seems that the other is the provider who by definition does not have a validator.
grab :: forall w s e. AsContractError e => Contract w s e ()
grab = do
utxos <- utxoAt scrAddress
let orefs = fst <$> Map.toList utxos
lookups = Constraints.unspentOutputs utxos <>
Constraints.otherScript validator -- ###### THIS LINE #####
tx :: TxConstraints Void Void
tx = mconcat [mustSpendScriptOutput oref $ Redeemer $ I 17 | oref <- orefs]
ledgerTx <- submitTxConstraintsWith @Void lookups tx
void $ awaitTxConfirmed $ txId ledgerTx
logInfo @String $ "collected gifts"