<p><code>data_hash</code> is always expected to be the same as the hash of the referenced <code>inline_datum_hash</code>. The existence of the latter simply shows that the datum is in fact inlined.</p>
<p>About your other question, you're right that the ledger rules technically allow to create an output that has a datum even if it's not locked by a script. In this case, the output is unspendable.</p>

CC BY-SA 4.0
2023-10-21T13:44:28.440Z
2023-10-21T13:44:28.440Z
Kostas Dermentzis
<p>I've this query on Preprod:</p>
<pre><code>SELECT
    ENCODE(TX.HASH, 'hex') as tx_hash,
    TX_OUT.INDEX,
    TX_OUT.ADDRESS_HAS_SCRIPT,
    ENCODE(TX_OUT.DATA_HASH,'hex') AS DATUM_HASH,
    SCRIPT.ID as script_id,
    TX_OUT.REFERENCE_SCRIPT_ID,
ENCODE(INLINE_DATUM.HASH,'hex') AS INLINE_DATUM_HASH
FROM TX_OUT
INNER JOIN TX ON TX.ID = TX_OUT.TX_ID
LEFT JOIN &quot;script&quot; ON &quot;script&quot;.&quot;hash&quot; = &quot;tx_out&quot;.&quot;payment_cred&quot;
LEFT JOIN &quot;datum&quot; AS &quot;inline_datum&quot; ON &quot;inline_datum&quot;.&quot;id&quot; = 
&quot;tx_out&quot;.&quot;inline_datum_id&quot;
WHERE TX.HASH = 
DECODE('8502fe3617b70d12fc65c8c17dab8483f5a7f847e0fba0376fe7abacf4773262','hex')
AND TX_OUT.INDEX = 3;
</code></pre>
<p>Where I'm getting some info about a specific <code>UTxO</code>. The result is this:</p>
<pre><code> tx_hash                                                          | index | address_has_script |                            datum_hash                            | script_id | reference_script_id |                        inline_datum_hash                         
------------------------------------------------------------------+-------+--------------------+------------------------------------------------------------------+-----------+---------------------+------------------------------------------------------------------
 8502fe3617b70d12fc65c8c17dab8483f5a7f847e0fba0376fe7abacf4773262 |     3 | f                  | 93892d0c469bd1228f0e94621d3101e755523e97ea0a837c9b509b1aeb9d8c42 |           |                     | 93892d0c469bd1228f0e94621d3101e755523e97ea0a837c9b509b1aeb9d8c42
</code></pre>
<p>You can see the <code>UTxO</code> doesn't have script <code>address_has_script = f</code> and left join to <code>script</code> table is null (<code>LEFT JOIN &quot;script&quot; ON &quot;script&quot;.&quot;hash&quot; = &quot;tx_out&quot;.&quot;payment_cred&quot;</code>) resulting on empty column <code>script_id</code>. The same goes to column <code>reference_script_id </code>.</p>
<p>So we can we can assume no script is involved in this <code>UTxO</code> but we can see it has <code>data_hash</code> and according to <code>db-sync</code> schema doc:</p>
<p><a href="https://i.sstatic.net/q55kB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/q55kB.png" alt="enter image description here" /></a></p>
<p>You can also notice the <code>UTxO</code> has inline datum (column <code>inline_datum_hash</code> in the query) which value is the same as <code>data_hash</code>. I know strictly speaking having <code>data_hash</code> doesn't mean it must have a <code>script</code> but I just cannot understand this <code>UTxO</code>.</p>
<p>Why <code>data_hash</code> is the same as <code>inline_datum_hash</code>, and what does it means?</p>

<cardano-db-sync>
Possible inconsistence data in db-sync
# Possible inconsistence data in db-sync

(Asked by: username_0 on 2022-12-05)

I've this query on Preprod:
SELECT
    ENCODE(TX.HASH, 'hex') as tx_hash,
    TX_OUT.INDEX,
    TX_OUT.ADDRESS_HAS_SCRIPT,
    ENCODE(TX_OUT.DATA_HASH,'hex') AS DATUM_HASH,
    SCRIPT.ID as script_id,
    TX_OUT.REFERENCE_SCRIPT_ID,
ENCODE(INLINE_DATUM.HASH,'hex') AS INLINE_DATUM_HASH
FROM TX_OUT
INNER JOIN TX ON TX.ID = TX_OUT.TX_ID
LEFT JOIN "script" ON "script"."hash" = "tx_out"."payment_cred"
LEFT JOIN "datum" AS "inline_datum" ON "inline_datum"."id" = 
"tx_out"."inline_datum_id"
WHERE TX.HASH = 
DECODE('8502fe3617b70d12fc65c8c17dab8483f5a7f847e0fba0376fe7abacf4773262','hex')
AND TX_OUT.INDEX = 3;

Where I'm getting some info about a specific UTxO. The result is this:
 tx_hash                                                          | index | address_has_script |                            datum_hash                            | script_id | reference_script_id |                        inline_datum_hash                         
------------------------------------------------------------------+-------+--------------------+------------------------------------------------------------------+-----------+---------------------+------------------------------------------------------------------
 8502fe3617b70d12fc65c8c17dab8483f5a7f847e0fba0376fe7abacf4773262 |     3 | f                  | 93892d0c469bd1228f0e94621d3101e755523e97ea0a837c9b509b1aeb9d8c42 |           |                     | 93892d0c469bd1228f0e94621d3101e755523e97ea0a837c9b509b1aeb9d8c42

You can see the UTxO doesn't have script address_has_script = f and left join to script table is null (LEFT JOIN "script" ON "script"."hash" = "tx_out"."payment_cred") resulting on empty column script_id. The same goes to column reference_script_id .
So we can we can assume no script is involved in this UTxO but we can see it has data_hash and according to db-sync schema doc:

You can also notice the UTxO has inline datum (column inline_datum_hash in the query) which value is the same as data_hash. I know strictly speaking having data_hash doesn't mean it must have a script but I just cannot understand this UTxO.
Why data_hash is the same as inline_datum_hash, and what does it means?

**Tags:** cardano-db-sync

---

## 1 answers

### Answer by username_1 on 2023-10-21. Score: 0

`data_hash` is always expected to be the same as the hash of the referenced `inline_datum_hash`. The existence of the latter simply shows that the datum is in fact inlined.

About your other question, you're right that the ledger rules technically allow to create an output that has a datum even if it's not locked by a script. In this case, the output is unspendable.


---

