I am trying to create a OffChain code for submitting inline datums.

gTest :: forall w s. GrabParams -> PlutusContract.Contract w s DataText.Text ()
gTest GrabParams{..} = do
    PlutusContract.logInfo @P.String $ TextPrintf.printf "------------------------------------------------------"
    PlutusContract.logInfo @P.String $ TextPrintf.printf "------------------- GTest endpoint -------------------"
    PlutusContract.logInfo @P.String $ TextPrintf.printf "------------------------------------------------------"
    maybeutxo <- findUtxoInValidator grabRedeem
    PlutusContract.logInfo @P.String $ TextPrintf.printf "datum utxos %s" (P.show maybeutxo)
    case maybeutxo of
        Nothing -> PlutusContract.logInfo @P.String $ TextPrintf.printf "Wrong guess %d" grabRedeem
        Just (oref, o) -> do
            PlutusContract.logInfo @P.String $ TextPrintf.printf "Redeem utxos %s" (P.show oref)
                d = OnChain.Dat
                          ddata = grabRedeem
                        , dtype = OnChain.Test
                r = OnChain.Redeem 
                        OnChain.redeem = grabRedeem
                q = 4000000
                lookups = Constraints.unspentOutputs (Map.singleton oref o) P.<>
                          Constraints.plutusV2OtherScript OnChain.validator
                tx = (Constraints.mustPayToOtherScriptWithDatumInTx OnChain.validatorHash (ScriptsLedger.Datum $ PlutusTx.toBuiltinData d) (lovelaceValueOf q)) <>
                     (Constraints.mustIncludeDatumInTx  (ScriptsLedger.Datum $ PlutusTx.toBuiltinData d)) <>
                     (Constraints.mustSpendScriptOutput oref $ ScriptsLedger.Redeemer $ PlutusTx.toBuiltinData r) 
            PlutusContract.logInfo @P.String $ TextPrintf.printf "[GTEST TX] %s" (P.show tx)            
            submittedTx <- PlutusContract.submitTxConstraintsWith @OnChain.Simple lookups tx
            Monad.void $ PlutusContract.awaitTxConfirmed $ LedgerTx.getCardanoTxId submittedTx
            PlutusContract.logInfo @P.String $ "collected gifts"

I even tried the Constraints.mustPayToOtherScriptWithInlineDatumInTx and still doesn't include the inline datum.

  • What plutus-apps tag/branch are you using? Oct 19, 2022 at 20:29

1 Answer 1


Constraint.mustPayToOtherScriptWithInlineDatumInTx doesn't exist on main branch. Use Constraint.mustPayToOtherScriptWithInlineDatum without other datum-related constraints to avoid conflict.

Your Answer

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

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