<p>I've tried to implement a logic which can spend 2 outputs of 2 different scripts and create 2 new UTxOs:</p>
<pre><code>lookups = Constraints.typedValidatorLookups instance1
          &lt;&gt; Constraints.otherScript script1
          &lt;&gt; Constraints.otherScript script2
          &lt;&gt; Constraints.unspentOutputs (Map.singleton txOutRef1 txOutTx1)
          &lt;&gt; Constraints.unspentOutputs (Map.singleton txOutRef2 txOutTx2)

tx = Constraints.mustPayToTheScript datum1 value1
          &lt;&gt; Constraints.mustSpendScriptOutput txOutRef1 redeemer
          &lt;&gt; Constraints.mustPayToOtherScript (validatorHash script2) (Datum $ PlutusTx.toData datum2) value2
          &lt;&gt; Constraints.mustSpendScriptOutput txOutRef2 redeemer

submitTxConstraintsWith lookups tx
</code></pre>
<p>But when I run the code, I'm faced with the error:</p>
<pre><code>WalletError (ValidationError (ScriptFailure (EvaluationError [])))
</code></pre>
<p>What am I missing?</p>

CC BY-SA 4.0
2021-07-20T13:59:31.533Z
Can you also share the validator function for both scripts? One of the scripts is not letting spend the output
AngelCastillo
CC BY-SA 4.0
2021-07-20T16:10:12.683Z
I've implemented on-chain function yet. I've implement off-chain first and tested it, so just having a validator return True value. I make sure this issue doesn't come to the validator
Richard Nguyen
CC BY-SA 4.0
2021-07-20T16:25:41.803Z
If I return false in the validator, the error is validator error message. But when I return true, the error above is presented. It's reason why I think the above error doesn't come from OnChain validator
Richard Nguyen
CC BY-SA 4.0
2021-08-01T20:08:01.253Z
It definitely looks as if the error happens in validation. Please share the code of both validators you are using - including the types you're using for datum and redeemer for both.
Lars Brünjes
<plutus>
How to spend two outputs of two different scripts
# How to spend two outputs of two different scripts

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

I've tried to implement a logic which can spend 2 outputs of 2 different scripts and create 2 new UTxOs:
lookups = Constraints.typedValidatorLookups instance1
          <> Constraints.otherScript script1
          <> Constraints.otherScript script2
          <> Constraints.unspentOutputs (Map.singleton txOutRef1 txOutTx1)
          <> Constraints.unspentOutputs (Map.singleton txOutRef2 txOutTx2)

tx = Constraints.mustPayToTheScript datum1 value1
          <> Constraints.mustSpendScriptOutput txOutRef1 redeemer
          <> Constraints.mustPayToOtherScript (validatorHash script2) (Datum $ PlutusTx.toData datum2) value2
          <> Constraints.mustSpendScriptOutput txOutRef2 redeemer

submitTxConstraintsWith lookups tx

But when I run the code, I'm faced with the error:
WalletError (ValidationError (ScriptFailure (EvaluationError [])))

What am I missing?

**Tags:** plutus
> **Comments:**
> **username_1**: Can you also share the validator function for both scripts? One of the scripts is not letting spend the output  
> **username_0**: I've implemented on-chain function yet. I've implement off-chain first and tested it, so just having a validator return True value. I make sure this issue doesn't come to the validator  
> **username_0**: If I return false in the validator, the error is validator error message. But when I return true, the error above is presented. It's reason why I think the above error doesn't come from OnChain validator  
> **username_2**: It definitely looks as if the error happens in validation. Please share the code of both validators you are using - including the types you're using for datum and redeemer for both.  

---

## 0 answers

