<p>There are at least two reasons for that field to be a list:</p>
<ul>
<li>A transaction may spend UTxO's from multiple script addresses,</li>
<li>The datum value for a transaction output can optionally be provided.</li>
</ul>
<p>Using <code>cardano-cli transaction build</code>, we can provide a datum value for each input UTxO with <code>--tx-in-datum-file</code> (or <code>--tx-in-datum-value</code>). And also, for each output UTxO we can provide a datum value with <code>--tx-out-datum-embed-file</code> (or <code>--tx-out-datum-embed-value</code>).</p>

CC BY-SA 4.0
2022-07-04T11:50:37.033Z
With the upcoming Babbage era the flag `--tx-out-inline-datum-file` and `--tx-out-inline-datum-value` will also be available.
Fermat
CC BY-SA 4.0
2022-07-04T09:53:23.847Z
2022-07-04T09:56:11.757Z
2022-07-04T09:56:11.757Z
keyanm
<p>TxInfoData can be obtained via the ScriptContext that is included as part of every transaction.  The list of datum and datum hashes is created when the transaction is submitted and made available to the plutus script.   Here are the relevant plutus docs <a href="https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Contexts.html" rel="nofollow noreferrer">https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Contexts.html</a>
Hope this helps.</p>

CC BY-SA 4.0
2022-06-16T21:00:28.507Z
2022-06-16T21:00:28.507Z
lley154
<p>I noticed that <a href="https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger/html/Ledger.html#t:TxInfo" rel="nofollow noreferrer"><code>TxInfo</code> datatype</a> has a <code>txInfoData</code> field which carries a list of mappings from datum hashes to datum values. This seems very useful for validating transactions with multiple input UTxO's.</p>
<p>Where and how is this list provided while creating a transaction?</p>

<transaction><datum><on-chain><datum-value><datum-hash>
Providing a list of mappings from datum hashes to values while creating a transaction
# Providing a list of mappings from datum hashes to values while creating a transaction

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

I noticed that [`TxInfo` datatype](https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger/html/Ledger.html#t:TxInfo) has a `txInfoData` field which carries a list of mappings from datum hashes to datum values. This seems very useful for validating transactions with multiple input UTxO's.

Where and how is this list provided while creating a transaction?

**Tags:** transaction, datum, on-chain, datum-value, datum-hash

---

## 2 answers

### Answer by username_0 on 2022-07-04. Score: 1 | Accepted answer

There are at least two reasons for that field to be a list:

* A transaction may spend UTxO's from multiple script addresses,
* The datum value for a transaction output can optionally be provided.

Using `cardano-cli transaction build`, we can provide a datum value for each input UTxO with `--tx-in-datum-file` (or `--tx-in-datum-value`). And also, for each output UTxO we can provide a datum value with `--tx-out-datum-embed-file` (or `--tx-out-datum-embed-value`).

> **Comments:**
> **username_1**: With the upcoming Babbage era the flag `--tx-out-inline-datum-file` and `--tx-out-inline-datum-value` will also be available.  

---

### Answer by username_2 on 2022-06-16. Score: 0

TxInfoData can be obtained via the ScriptContext that is included as part of every transaction. The list of datum and datum hashes is created when the transaction is submitted and made available to the plutus script. Here are the relevant plutus docs <https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Contexts.html>
Hope this helps.


---

