<blockquote>
<p>The grabber is the consumer of the UTXO and thus the burden of providing the validator is on him, not the provider.</p>
</blockquote>
<p>Correct! And I feel like this might be where your misunderstanding is.</p>
<p>You are right that &quot;the burden of providing the validator&quot; is on the grabber. The <code>grab</code> and <code>give</code> functions are called <em>offchain</em> to construct txs to perform those actions. So the line in question is in fact the code where the grabber &quot;provid[es] the validator.&quot;</p>
<p>The <code>Constraits</code> are a way to <em>declaratively</em> specify</p>
<ol>
<li>What kind of script and UTxOs you want to target with your tx (lookups)</li>
<li>What kind of tx you want to send (tx)</li>
</ol>
<p>When we include</p>
<pre><code>Constraints.otherScript validator
</code></pre>
<p>we are just saying that we want to target our <code>validator</code> with your <code>tx</code>. Or, it might be more accurate to say, we will need our <code>validator</code> in order to perform the <code>tx</code>.</p>
<hr />
<p>Admittedly the name of the function as well as the documentation doesn't shed too much light on what it's doing:</p>
<pre><code>-- | A script lookups value with a validator script
otherScript :: Validator -&gt; ScriptLookups a
otherScript vl =
    let addr = Address.scriptAddress vl in
    mempty { slOtherScripts = Map.singleton addr vl }
</code></pre>

CC BY-SA 4.0
2021-07-20T17:33:07.453Z
So `otherScript` really means `ourScript`? This is very confusing.
Lo HaBuyshan
CC BY-SA 4.0
2021-07-20T17:53:35.677Z
That's not quite right. Maybe think of it as adding "another" script to the lookups. You could theoretically include multiple validators if you're spending outputs from different scripts in a single transaction. Remember, validators just check if you are allowed to spend outputs at a script address.
Mitchell Turner
CC BY-SA 4.0
2021-07-20T18:09:29.187Z
So it seems that in this particular case for grabbing, since there is only one grabber (at a time), there is just one validator. And hence there is no ambiguity in simply stating `otherScript` because there's just one script out there altogether for this particular transaction.
Lo HaBuyshan
CC BY-SA 4.0
2021-07-20T17:14:08.853Z
2021-07-20T17:14:08.853Z
Mitchell Turner
<p>In <code>gift.hs</code>, I do not understand the logic for why in the <em>lookups</em> for the <code>grab</code> contract there is <code>Constraints.otherScript validator</code>. 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 <em>other</em> is the provider who by definition does <strong>not</strong> have a validator.</p>
<pre><code>grab :: forall w s e. AsContractError e =&gt; Contract w s e ()
grab = do
   utxos &lt;- utxoAt scrAddress
   let orefs   = fst &lt;$&gt; Map.toList utxos
      lookups  = Constraints.unspentOutputs utxos      &lt;&gt;
                 Constraints.otherScript validator -- ###### THIS LINE #####
      tx :: TxConstraints Void Void
      tx       = mconcat [mustSpendScriptOutput oref $ Redeemer $ I 17 | oref &lt;- orefs]
   ledgerTx &lt;- submitTxConstraintsWith @Void lookups tx
   void $ awaitTxConfirmed $ txId ledgerTx
   logInfo @String $ &quot;collected gifts&quot;
</code></pre>

<plutus-pioneer-program>
Plutus Pioneer Week02: otherScript validator
# Plutus Pioneer Week02: otherScript validator

(Asked by: username_0 on 2021-07-20)

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"

```

**Tags:** plutus-pioneer-program


---

## 1 answers

### Answer by username_1 on 2021-07-20. Score: 1 | Accepted answer

> The grabber is the consumer of the UTXO and thus the burden of providing the validator is on him, not the provider.

Correct! And I feel like this might be where your misunderstanding is.

You are right that "the burden of providing the validator" is on the grabber. The `grab` and `give` functions are called *offchain* to construct txs to perform those actions. So the line in question is in fact the code where the grabber "provid[es] the validator."

The `Constraits` are a way to *declaratively* specify

1. What kind of script and UTxOs you want to target with your tx (lookups)
2. What kind of tx you want to send (tx)

When we include

```
Constraints.otherScript validator

```

we are just saying that we want to target our `validator` with your `tx`. Or, it might be more accurate to say, we will need our `validator` in order to perform the `tx`.

---

Admittedly the name of the function as well as the documentation doesn't shed too much light on what it's doing:

```
-- | A script lookups value with a validator script
otherScript :: Validator -> ScriptLookups a
otherScript vl =
    let addr = Address.scriptAddress vl in
    mempty { slOtherScripts = Map.singleton addr vl }

```

> **Comments:**
> **username_0**: So `otherScript` really means `ourScript`? This is very confusing.  
> **username_1**: That's not quite right. Maybe think of it as adding "another" script to the lookups. You could theoretically include multiple validators if you're spending outputs from different scripts in a single transaction. Remember, validators just check if you are allowed to spend outputs at a script address.  
> **username_0**: So it seems that in this particular case for grabbing, since there is only one grabber (at a time), there is just one validator. And hence there is no ambiguity in simply stating `otherScript` because there's just one script out there altogether for this particular transaction.  

---

