As far as I understand the function Constraints.mustPayToTheScript :: forall i o. ToData o => o -> Value -> TxConstraints i o is used to command: Hey, pay some money, Value, to the script and record o as Datum in the chain.

How could I pay to a script recording the Datum hash?

2 Answers 2


Let's say you have a Datum like this one:

let d = MyDatum
          { someField = 1
          , someOtherField = 2

And a script:

let lookups = typedValidatorLookups myScriptInstance
              <> otherScript myScriptValidator

Then you can call the function as follows:

let tx = mustPayToTheScript d $ Ada.lovelaceValueOf 1_000_000

And then submit the transaction if you want:

ledgerTx <- mkTxConstraints @MyValidatorTypes lookups tx >>= submitUnbalancedTx . adjustUnbalancedTx
awaitTxConfirmed $ getCardanoTxId ledgerTx
  • Thanks @Jey, but my question is about how to record the datum hash (not the datum). I only want the hash of datum in the chain.
    – kindofdev
    Jan 18 at 23:10
  • You could try to strip the datum from the transaction before submitting it. But I think that would make it malformed.
    – Jey
    Jan 19 at 7:58

I asked my question in Q&A session 2 (3 cohort) to Lars.

His response was that currently is not possible to do it (store only the UTXO's DatumHash (not Datum) in the chain) using PAB. However it is possible using with Cardano Cli.

Your Answer

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

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