<p>According to CDDL, the transaction output itself has a <code>data_hash</code>: <a href="https://github.com/input-output-hk/cardano-ledger/blob/37322df14d44d1370e8a72b677815d64a92baa00/alonzo/test/cddl-files/alonzo.cddl#L73" rel="nofollow noreferrer">https://github.com/input-output-hk/cardano-ledger/blob/37322df14d44d1370e8a72b677815d64a92baa00/alonzo/test/cddl-files/alonzo.cddl#L73</a></p>
<p>PS: I can't believe I missed that...</p>

CC BY-SA 4.0
2022-06-28T22:30:50.517Z
2022-06-28T22:30:50.517Z
Pedro Martins Timóteo da Costa
<p>Looking at the <a href="https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/schema.md#tx_out" rel="nofollow noreferrer">db-sync schema</a>, I see the <code>tx_out</code> table has a <code>data_hash</code> column, but I can't make sense of why this column is not on the <code>tx</code> table instead. From the <a href="https://github.com/input-output-hk/cardano-ledger/blob/37322df14d44d1370e8a72b677815d64a92baa00/alonzo/test/cddl-files/alonzo.cddl" rel="nofollow noreferrer">Alonzo CDDL</a>, I can see the scripts are part of the <code>transaction_witness_sets</code>, which is part of the block, so I don't see how one could match a script data from a witness to an output in a transaction.</p>

<cardano-db-sync>
How can db-sync "match" a data_hash to specific outputs?
# How can db-sync "match" a data_hash to specific outputs?

(Asked by: username_0 on 2022-06-28)

Looking at the [db-sync schema](https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/schema.md#tx_out), I see the `tx_out` table has a `data_hash` column, but I can't make sense of why this column is not on the `tx` table instead. From the [Alonzo CDDL](https://github.com/input-output-hk/cardano-ledger/blob/37322df14d44d1370e8a72b677815d64a92baa00/alonzo/test/cddl-files/alonzo.cddl), I can see the scripts are part of the `transaction_witness_sets`, which is part of the block, so I don't see how one could match a script data from a witness to an output in a transaction.

**Tags:** cardano-db-sync

---

## 1 answers

### Answer by username_0 on 2022-06-28. Score: 3 | Accepted answer

According to CDDL, the transaction output itself has a `data_hash`: <https://github.com/input-output-hk/cardano-ledger/blob/37322df14d44d1370e8a72b677815d64a92baa00/alonzo/test/cddl-files/alonzo.cddl#L73>

PS: I can't believe I missed that...


---

