So I have a validator that, in particular, checks how many outputs are produced. os = txInfoOutputs info

mkValidator :: ...
mkValidator = traceIfFalse "Wrong outputs" checkOutput
    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 22bbd35920a7a027d367e55b292e4321ede0d7d55939a56bd036cf2e5979f30d:
                    - 92abe5e3f5f3f0c5606d3bec6b7d3cb282c83f27cf36af30ad0371dba94b73d9!20
                    - 92abe5e3f5f3f0c5606d3bec6b7d3cb282c83f27cf36af30ad0371dba94b73d9!21
                 collateral inputs:
                   - 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 [])
                 validity range: Interval {ivFrom = LowerBound NegInf True, ivTo = UpperBound PosInf True}
                   <<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.

  • 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.
    – kolam
    Aug 24 at 12:23
  • 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. Aug 24 at 18:53
  • have you tried the same code in the plutus playground? Do you know if the PAB includes gas fees?
    – GClaramunt
    Aug 25 at 17:41
  • 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 Aug 29 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.