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.