<p>So I have a validator that, in particular, checks how many outputs are produced.
<code>os = txInfoOutputs info</code></p>
<pre><code>mkValidator :: ...
mkValidator = traceIfFalse &quot;Wrong outputs&quot; checkOutput
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    checkOutput :: Bool
    checkOutput = let os = txInfoOutputs info in
                  length os == 2 

</code></pre>
<p>I know, thanks to PAB outputs that there are two outputs from my transaction, so I want my validator to validate that there are indeed two outputs : <code>length os == 2</code>.
When I write <code>length os &gt; 1</code> it returns True, everything goes as planned, as it should.
When I write <code>length os &gt; 2</code> it is False, the contract outputs an error and stops, as it should.
But when I write <code>length os == 2</code> it does not validate but instead I have this :</p>
<pre><code>Slot 00003: W1: TxSubmit: c198a060020e58b3e3df37da4be3e6d265a48caa8dd0aaf256fed18aa4244828
Slot 00003: TxnValidationFail Phase2 c198a060020e58b3e3df37da4be3e6d265a48caa8dd0aaf256fed18aa4244828: ScriptFailure (EvaluationError [&quot;Wrong outputs&quot;])
Slot 00004: *** CONTRACT LOG: &quot;Done&quot;
</code></pre>
<p>This <code>&quot;Done&quot;</code> message is defined as following :</p>
<pre><code>ledgerTx &lt;- submitTxConstraintsWith lookups tx
void $ awaitTxConfirmed $ txId ledgerTx
logInfo @String &quot;Done&quot;
</code></pre>
<p>So it should only be displayed when the Tx is confirmed. It clearly is not here when I check the balances afterwards. The weird thing is also that I don't have an error but a warning (I see this in PAB log) and the off-chain code goes on as the tx was validated.</p>
<p>Last weird behavior is that after this &quot;semi-validated&quot; tx, Wallet 1 (on which the contract is run) is gone. Its ADA balance is empty, and not just display bug, when I try another Tx after this, I get an error for insufficient funds. Whereas when the Error is real, when the contract stops (for example when the validator is <code>length os &gt; 2</code>) the balance of wallet 1 is unchanged since on Cardano we don't pay fees for invalid transactions.</p>
<p>Plutus <code>tag : 7b5829f2ac57fcfa25a5969ff602b48641b36ac3</code> (Second Cohort Lecture 10, Plutus Pioneer Program)</p>
<p>Here is a complete PAB output for the transaction, with the Tx details :</p>
<pre><code>[INFO] W1: Balancing an unbalanced transaction:
             Tx:
               Tx 22bbd35920a7a027d367e55b292e4321ede0d7d55939a56bd036cf2e5979f30d:
                 {inputs:
                    - 92abe5e3f5f3f0c5606d3bec6b7d3cb282c83f27cf36af30ad0371dba94b73d9!20
                      &lt;&gt;
                    - 92abe5e3f5f3f0c5606d3bec6b7d3cb282c83f27cf36af30ad0371dba94b73d9!21
                      &lt;&gt;
                 collateral inputs:
                 outputs:
                   - Value (Map [(a37ef7cfe1af45ac35b307abd9c26bad4bbcfe75d0d13ed90b4d8fd4,Map [(&quot;NFT3&quot;,1)])]) addressed to
                     addressed to ScriptCredential: 88b9547195adbac7487a52e27f48766a2bab50d78e396e18e4bf7574 (no staking credential)
                   - Value (Map [(a37ef7cfe1af45ac35b307abd9c26bad4bbcfe75d0d13ed90b4d8fd4,Map [(&quot;NFT1&quot;,1)])]) addressed to
                     addressed to PubKeyCredential: bcc083ade3fdd0a372cb6c43ef00ef02fcb52e9532941117d7609d6a (no staking credential)
                 mint: Value (Map [])
                 fee: Value (Map [])
                 mps:
                 signatures:
                 validity range: Interval {ivFrom = LowerBound NegInf True, ivTo = UpperBound PosInf True}
                 data:
                   &lt;&lt;20&gt;, 2, &quot;NFT2&quot;&gt;
                   &lt;&lt;20&gt;, 1, &quot;NFT1&quot;&gt;}
             Requires signatures:
             Utxo index:
               ( 92abe5e3f5f3f0c5606d3bec6b7d3cb282c83f27cf36af30ad0371dba94b73d9!20
               , - Value (Map [(a37ef7cfe1af45ac35b307abd9c26bad4bbcfe75d0d13ed90b4d8fd4,Map [(&quot;NFT1&quot;,1)])]) addressed to
                   addressed to ScriptCredential: 88b9547195adbac7487a52e27f48766a2bab50d78e396e18e4bf7574 (no staking credential) )
               ( 92abe5e3f5f3f0c5606d3bec6b7d3cb282c83f27cf36af30ad0371dba94b73d9!21
               , - Value (Map [(a37ef7cfe1af45ac35b307abd9c26bad4bbcfe75d0d13ed90b4d8fd4,Map [(&quot;NFT3&quot;,1)])]) addressed to
                   addressed to ScriptCredential: 88b9547195adbac7487a52e27f48766a2bab50d78e396e18e4bf7574 (no staking credential) )
             Validity range:
               (-∞ , +∞)
[INFO] W1: Finished balancing. 24d1a8fc3ac99077bed9d04282f18b3f40aff2a89468ca5bfa1a77b52a34d921
[INFO] W1: Submitting tx: 24d1a8fc3ac99077bed9d04282f18b3f40aff2a89468ca5bfa1a77b52a34d921
[WARNING] Slot 121: TxnValidationFail Phase2 24d1a8fc3ac99077bed9d04282f18b3f40aff2a89468ca5bfa1a77b52a34d921: ScriptFailure (EvaluationError [&quot;No other outputs allowed&quot;,&quot;Pd&quot;] &quot;CekEvaluationFailure&quot;)
[INFO] 63e43944-1885-44aa-b7c8-d6aa7f369438: &quot;Done&quot;
</code></pre>
<p>Thanks for any opinion on this.</p>

CC BY-SA 4.0
2021-08-24T12:23:24.963Z
Do you have a complete example to illustrate the described behavior? I tried a simple give/grab contract (similar to the one in lecture 2 of the Plutus Pioneer Program) with the same validator as you, but I don't see the issue. In my case, if the validator fails, then the log message isn't displayed as I get an error and not a warning.
kolam
CC BY-SA 4.0
2021-08-24T18:53:05.797Z
What exactly do you want to know or see? So I don't post too long code here. I'll post the entire PAB output leading to the warning. And I'll try to reproduce the error with a as small as possible code and I'll post the Github link here to it.
Alain Magazin
CC BY-SA 4.0
2021-08-25T17:41:41.967Z
have you tried the same code in the plutus playground? 
Do you know if the PAB includes gas fees?
GClaramunt
CC BY-SA 4.0
2021-08-29T21:31:59.487Z
It does not work in EMU neither, haven't tried the playground. I had thought of fees but why this in between return? If fees are considered a real output, the return should be a real false. I use this as a workaround `length os > 1 && length os <= 3`
Alain Magazin
<plutus><smart-contract><simulator><script><output>
Weird behavior on validation of outputs
# Weird behavior on validation of outputs

(Asked by: username_0 on 2021-08-23)

So I have a validator that, in particular, checks how many outputs are produced.
os = txInfoOutputs info
mkValidator :: ...
mkValidator = traceIfFalse "Wrong outputs" checkOutput
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    checkOutput :: Bool
    checkOutput = let os = txInfoOutputs info in
                  length os == 2 


I know, thanks to PAB outputs that there are two outputs from my transaction, so I want my validator to validate that there are indeed two outputs : length os == 2.
When I write length os > 1 it returns True, everything goes as planned, as it should.
When I write length os > 2 it is False, the contract outputs an error and stops, as it should.
But when I write length os == 2 it does not validate but instead I have this :
Slot 00003: W1: TxSubmit: c198a060020e58b3e3df37da4be3e6d265a48caa8dd0aaf256fed18aa4244828
Slot 00003: TxnValidationFail Phase2 c198a060020e58b3e3df37da4be3e6d265a48caa8dd0aaf256fed18aa4244828: ScriptFailure (EvaluationError ["Wrong outputs"])
Slot 00004: *** CONTRACT LOG: "Done"

This "Done" message is defined as following :
ledgerTx <- submitTxConstraintsWith lookups tx
void $ awaitTxConfirmed $ txId ledgerTx
logInfo @String "Done"

So it should only be displayed when the Tx is confirmed. It clearly is not here when I check the balances afterwards. The weird thing is also that I don't have an error but a warning (I see this in PAB log) and the off-chain code goes on as the tx was validated.
Last weird behavior is that after this "semi-validated" tx, Wallet 1 (on which the contract is run) is gone. Its ADA balance is empty, and not just display bug, when I try another Tx after this, I get an error for insufficient funds. Whereas when the Error is real, when the contract stops (for example when the validator is length os > 2) the balance of wallet 1 is unchanged since on Cardano we don't pay fees for invalid transactions.
Plutus tag : 7b5829f2ac57fcfa25a5969ff602b48641b36ac3 (Second Cohort Lecture 10, Plutus Pioneer Program)
Here is a complete PAB output for the transaction, with the Tx details :
[INFO] W1: Balancing an unbalanced transaction:
             Tx:
               Tx 22bbd35920a7a027d367e55b292e4321ede0d7d55939a56bd036cf2e5979f30d:
                 {inputs:
                    - 92abe5e3f5f3f0c5606d3bec6b7d3cb282c83f27cf36af30ad0371dba94b73d9!20
                      <>
                    - 92abe5e3f5f3f0c5606d3bec6b7d3cb282c83f27cf36af30ad0371dba94b73d9!21
                      <>
                 collateral inputs:
                 outputs:
                   - Value (Map [(a37ef7cfe1af45ac35b307abd9c26bad4bbcfe75d0d13ed90b4d8fd4,Map [("NFT3",1)])]) addressed to
                     addressed to ScriptCredential: 88b9547195adbac7487a52e27f48766a2bab50d78e396e18e4bf7574 (no staking credential)
                   - Value (Map [(a37ef7cfe1af45ac35b307abd9c26bad4bbcfe75d0d13ed90b4d8fd4,Map [("NFT1",1)])]) addressed to
                     addressed to PubKeyCredential: bcc083ade3fdd0a372cb6c43ef00ef02fcb52e9532941117d7609d6a (no staking credential)
                 mint: Value (Map [])
                 fee: Value (Map [])
                 mps:
                 signatures:
                 validity range: Interval {ivFrom = LowerBound NegInf True, ivTo = UpperBound PosInf True}
                 data:
                   <<20>, 2, "NFT2">
                   <<20>, 1, "NFT1">}
             Requires signatures:
             Utxo index:
               ( 92abe5e3f5f3f0c5606d3bec6b7d3cb282c83f27cf36af30ad0371dba94b73d9!20
               , - Value (Map [(a37ef7cfe1af45ac35b307abd9c26bad4bbcfe75d0d13ed90b4d8fd4,Map [("NFT1",1)])]) addressed to
                   addressed to ScriptCredential: 88b9547195adbac7487a52e27f48766a2bab50d78e396e18e4bf7574 (no staking credential) )
               ( 92abe5e3f5f3f0c5606d3bec6b7d3cb282c83f27cf36af30ad0371dba94b73d9!21
               , - Value (Map [(a37ef7cfe1af45ac35b307abd9c26bad4bbcfe75d0d13ed90b4d8fd4,Map [("NFT3",1)])]) addressed to
                   addressed to ScriptCredential: 88b9547195adbac7487a52e27f48766a2bab50d78e396e18e4bf7574 (no staking credential) )
             Validity range:
               (-∞ , +∞)
[INFO] W1: Finished balancing. 24d1a8fc3ac99077bed9d04282f18b3f40aff2a89468ca5bfa1a77b52a34d921
[INFO] W1: Submitting tx: 24d1a8fc3ac99077bed9d04282f18b3f40aff2a89468ca5bfa1a77b52a34d921
[WARNING] Slot 121: TxnValidationFail Phase2 24d1a8fc3ac99077bed9d04282f18b3f40aff2a89468ca5bfa1a77b52a34d921: ScriptFailure (EvaluationError ["No other outputs allowed","Pd"] "CekEvaluationFailure")
[INFO] 63e43944-1885-44aa-b7c8-d6aa7f369438: "Done"

Thanks for any opinion on this.

**Tags:** plutus, smart-contract, simulator, script, output
> **Comments:**
> **username_1**: Do you have a complete example to illustrate the described behavior? I tried a simple give/grab contract (similar to the one in lecture 2 of the Plutus Pioneer Program) with the same validator as you, but I don't see the issue. In my case, if the validator fails, then the log message isn't displayed as I get an error and not a warning.  
> **username_0**: What exactly do you want to know or see? So I don't post too long code here. I'll post the entire PAB output leading to the warning. And I'll try to reproduce the error with a as small as possible code and I'll post the Github link here to it.  
> **username_2**: have you tried the same code in the plutus playground?  Do you know if the PAB includes gas fees?  
> **username_0**: It does not work in EMU neither, haven't tried the playground. I had thought of fees but why this in between return? If fees are considered a real output, the return should be a real false. I use this as a workaround `length os > 1 && length os <= 3`  

---

## 0 answers

