<p>If you are running a DbSync node you can retrieve the datum and redeemer:</p>
<h3><code>redeemer</code></h3>
<p>A table containing redeemers. A redeemer is provided for all items that are validated by a script.</p>
<ul>
<li>Primary Id: <code>id</code></li>
</ul>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Column name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>id</code></td>
<td>integer (64)</td>
<td></td>
</tr>
<tr>
<td><code>tx_id</code></td>
<td>integer (64)</td>
<td>The Tx table index that contains this redeemer.</td>
</tr>
<tr>
<td><code>unit_mem</code></td>
<td>word63type</td>
<td>The budget in Memory to run a script.</td>
</tr>
<tr>
<td><code>unit_steps</code></td>
<td>word63type</td>
<td>The budget in Cpu steps to run a script.</td>
</tr>
<tr>
<td><code>fee</code></td>
<td>lovelace</td>
<td>The budget in fees to run a script. The fees depend on the ExUnits and the current prices.</td>
</tr>
<tr>
<td><code>purpose</code></td>
<td>scriptpurposetype</td>
<td>What kind pf validation this redeemer is used for. It can be one of 'spend', 'mint', 'cert', 'reward'.</td>
</tr>
<tr>
<td><code>index</code></td>
<td>uinteger</td>
<td>The index of the redeemer pointer in the transaction.</td>
</tr>
<tr>
<td><code>script_hash</code></td>
<td>hash28type</td>
<td>The script hash this redeemer is used for.</td>
</tr>
<tr>
<td><code>datum_id</code></td>
<td>integer (64)</td>
<td></td>
</tr>
</tbody>
</table>
</div><h3><code>datum</code></h3>
<p>A table containing Plutus Data available in the blockchain, found in redeemers or witnesses</p>
<ul>
<li>Primary Id: <code>id</code></li>
</ul>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Column name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>id</code></td>
<td>integer (64)</td>
<td></td>
</tr>
<tr>
<td><code>hash</code></td>
<td>hash32type</td>
<td>The Hash of the Plutus Data</td>
</tr>
<tr>
<td><code>tx_id</code></td>
<td>integer (64)</td>
<td>The Tx table index for the transaction where this script first became available.</td>
</tr>
<tr>
<td><code>value</code></td>
<td>jsonb</td>
<td>The actual data in json format</td>
</tr>
</tbody>
</table>
</div>
<p>Taken from dbSync:</p>
<p><a href="https://github.com/input-output-hk/cardano-db-sync" rel="noreferrer">https://github.com/input-output-hk/cardano-db-sync</a></p>
<p>It is also possible by just inspecting the blockchain. Even tho only the Datum hash is attached to the eUTXO, the datum value should be in the witness set of the transaction that created such eUTXO, so we should be able to:</p>
<p>a) Get the datum hash from the eUTXO and then.</p>
<p>b) Get the transaction that created such eUTXO and use the hash to retrieve the actual datum data.</p>
<p>Otherwise, if the Datum were not present at all on the chain it would be impossible to re-validate the blockchain from scratch.</p>

CC BY-SA 4.0
2022-03-07T21:43:47.440Z
As per the comments on this PR the datum is included in the TX that spends the corresponding eUTXO rather than on the one that creates it. https://github.com/input-output-hk/cardano-db-sync/issues/1076
Jesuspc
CC BY-SA 4.0
2022-03-08T06:33:09.130Z
It is possible to just add the datum hash when creating a transaction, in which case the actual datum value won't be included in the witness set of the transaction that creates the output, however, it is also possible to add the datum value at creation of the transaction if you use the flag "tx-out-datum-embed-file" or "tx-out-datum-embed-value" on the CLI and add the datum value, in which case, the datum value will be available on chain from the creation of the eUTXO.
AngelCastillo
CC BY-SA 4.0
2022-12-03T13:55:28.603Z
This solution somehow doesn't work for tx `034cd38f3f8387e6963c78175e459a2ffab0e36becb36510aaa81534f6ea6e54`
I can't find the datum for this tx in cardano db sync.
Displee
CC BY-SA 4.0
2021-12-16T04:44:56.577Z
2021-12-16T04:44:56.577Z
AngelCastillo
<p>How do I get the datum of an output from cardano-graphql (or another service)? I have attached it using the <code>--tx-out-datum-embed-file</code> flag already when building the tx using <code>cardano-cli</code>.</p>
<p>Thanks!</p>

<plutus><cardano-cli><transaction><datum><cardano-graphql>
How do I read the datum of an output?
# How do I read the datum of an output?

(Asked by: username_0 on 2021-12-15)

How do I get the datum of an output from cardano-graphql (or another service)? I have attached it using the `--tx-out-datum-embed-file` flag already when building the tx using `cardano-cli`.

Thanks!

**Tags:** plutus, cardano-cli, transaction, datum, cardano-graphql

---

## 1 answers

### Answer by username_1 on 2021-12-16. Score: 5 | Accepted answer

If you are running a DbSync node you can retrieve the datum and redeemer:

### `redeemer`

A table containing redeemers. A redeemer is provided for all items that are validated by a script.

* Primary Id: `id`

| Column name | Type | Description |
| --- | --- | --- |
| `id` | integer (64) |  |
| `tx_id` | integer (64) | The Tx table index that contains this redeemer. |
| `unit_mem` | word63type | The budget in Memory to run a script. |
| `unit_steps` | word63type | The budget in Cpu steps to run a script. |
| `fee` | lovelace | The budget in fees to run a script. The fees depend on the ExUnits and the current prices. |
| `purpose` | scriptpurposetype | What kind pf validation this redeemer is used for. It can be one of 'spend', 'mint', 'cert', 'reward'. |
| `index` | uinteger | The index of the redeemer pointer in the transaction. |
| `script_hash` | hash28type | The script hash this redeemer is used for. |
| `datum_id` | integer (64) |  |

### `datum`

A table containing Plutus Data available in the blockchain, found in redeemers or witnesses

* Primary Id: `id`

| Column name | Type | Description |
| --- | --- | --- |
| `id` | integer (64) |  |
| `hash` | hash32type | The Hash of the Plutus Data |
| `tx_id` | integer (64) | The Tx table index for the transaction where this script first became available. |
| `value` | jsonb | The actual data in json format |

Taken from dbSync:

<https://github.com/input-output-hk/cardano-db-sync>

It is also possible by just inspecting the blockchain. Even tho only the Datum hash is attached to the eUTXO, the datum value should be in the witness set of the transaction that created such eUTXO, so we should be able to:

a) Get the datum hash from the eUTXO and then.

b) Get the transaction that created such eUTXO and use the hash to retrieve the actual datum data.

Otherwise, if the Datum were not present at all on the chain it would be impossible to re-validate the blockchain from scratch.

> **Comments:**
> **username_2**: As per the comments on this PR the datum is included in the TX that spends the corresponding eUTXO rather than on the one that creates it. https://github.com/input-output-hk/cardano-db-sync/issues/1076  
> **username_1**: It is possible to just add the datum hash when creating a transaction, in which case the actual datum value won't be included in the witness set of the transaction that creates the output, however, it is also possible to add the datum value at creation of the transaction if you use the flag "tx-out-datum-embed-file" or "tx-out-datum-embed-value" on the CLI and add the datum value, in which case, the datum value will be available on chain from the creation of the eUTXO.  
> **username_3**: This solution somehow doesn't work for tx `034cd38f3f8387e6963c78175e459a2ffab0e36becb36510aaa81534f6ea6e54` I can't find the datum for this tx in cardano db sync.  

---

