<p>I asked my question in Q&amp;A session 2 (3 cohort) to Lars.</p>
<p>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.</p>

CC BY-SA 4.0
2022-01-25T17:18:46.143Z
2022-01-25T17:18:46.143Z
kindofdev
<p>Let's say you have a <code>Datum</code> like this one:</p>
<pre><code>let d = MyDatum
          { someField = 1
          , someOtherField = 2
          }
</code></pre>
<p>And a script:</p>
<pre><code>let lookups = typedValidatorLookups myScriptInstance
              &lt;&gt; otherScript myScriptValidator
</code></pre>
<p>Then you can call the function as follows:</p>
<pre><code>let tx = mustPayToTheScript d $ Ada.lovelaceValueOf 1_000_000
</code></pre>
<p>And then submit the transaction if you want:</p>
<pre><code>ledgerTx &lt;- mkTxConstraints @MyValidatorTypes lookups tx &gt;&gt;= submitUnbalancedTx . adjustUnbalancedTx
awaitTxConfirmed $ getCardanoTxId ledgerTx
</code></pre>

CC BY-SA 4.0
2022-01-18T23:10:03.910Z
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
CC BY-SA 4.0
2022-01-19T07:58:07.043Z
You could try to strip the datum from the transaction before submitting it. But I think that would make it malformed.
Jey
CC BY-SA 4.0
2022-01-18T21:50:47.730Z
2022-01-18T21:50:47.730Z
Jey
<p>As far as I understand the function <code>Constraints.mustPayToTheScript :: forall i o. ToData o =&gt; o -&gt; Value -&gt; TxConstraints i o </code> is used to command: Hey, pay some money, <strong>Value</strong>, to the script and record <strong>o</strong> as Datum in the chain.</p>
<p>How could I pay to a script recording the Datum hash?</p>

<plutus><plutus-pioneer-program>
How to payToTheScript recording the Datum hash?
# How to payToTheScript recording the Datum hash?

(Asked by: username_0 on 2022-01-18)

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?

**Tags:** plutus, plutus-pioneer-program

---

## 2 answers

### Answer by username_0 on 2022-01-25. Score: 1 | Accepted answer

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.


---

### Answer by username_1 on 2022-01-18. Score: 3

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

> **Comments:**
> **username_0**: 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.  
> **username_1**: You could try to strip the datum from the transaction before submitting it. But I think that would make it malformed.  

---

