0

Before the 2022-04-06 PAB Release Contracts used to stop execution after validation script failed the transaction sent by submitTxConstraintsWith, but after this release Contract is not stopping its execution anymore and it's just proceeding to the end.

The suspected change which caused this changed behavior is this one https://github.com/input-output-hk/plutus-apps/pull/360/files

I need to update our code base to accommodate this recent change in behavior in Contract monad.

ledgerTx <- submitTxConstraintsWith @Void lookups tx
logInfo @String $ "In case if validation fails, this line was not reachable before 2022-04-06 release, but now it is"

There is some logic follows after submitTxConstraintsWith called, that logic should not be executed in case if validation script fails.

What would be the best way to check if validator script failed the transaction to throw an error and make the Contract return?

1 Answer 1

1

Found the way to address this problem

    statusChange <- awaitTxStatusChange . getCardanoTxId $ ledgerTx
case statusChange of
    Committed TxInvalid () -> logError @String "Transaction failed"
    Committed TxValid -> logInfo @String "Transaction successful"
    _ -> logInfo @String "something else"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.