0

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)
            let 
                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.

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

1 Answer 1

0

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 you have read our privacy policy.

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