<p>The transaction metadata lives outside of the transaction body, inside of the <code>auxiliary_data</code>. In the Babbage ledger era, you can see this in the wire spec (CDDL)
<a href="https://github.com/input-output-hk/cardano-ledger/blob/fc4734c93d60158f2db04b416266268d0261c443/eras/babbage/test-suite/cddl-files/babbage.cddl#L17" rel="nofollow noreferrer">here</a>
In particular, the metadata is defined
<a href="https://github.com/input-output-hk/cardano-ledger/blob/fc4734c93d60158f2db04b416266268d0261c443/eras/babbage/test-suite/cddl-files/babbage.cddl#L329-L337" rel="nofollow noreferrer">here</a>.</p>
<p>In Haskell, you can see that the metadata is
<a href="https://github.com/input-output-hk/cardano-ledger/blob/fc4734c93d60158f2db04b416266268d0261c443/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Data.hs#L241y" rel="nofollow noreferrer">defined</a>
as a map from <code>Word64</code> to <code>Metadatum</code>.
(I've chosen the Alonzo auxiliary data type to link to here, which is re-used by the Babbage era).</p>
<p>And <code>Metadatum</code> is the JSON-like structure defined
<a href="https://github.com/input-output-hk/cardano-ledger/blob/fc4734c93d60158f2db04b416266268d0261c443/eras/shelley/impl/src/Cardano/Ledger/Shelley/Metadata.hs#L65-L72" rel="nofollow noreferrer">here</a>.</p>
<hr />
<p><strong>Note</strong> that the transaction metadata is a different type than the <code>Datum</code> type used by Plutus, though the structure is nearly identical. (<code>txData</code> contains <code>Datum</code>, not <code>Metadatum</code>.)</p>
<hr />
<p><a href="https://cips.cardano.org/cips/cip25/" rel="nofollow noreferrer">CIP-25</a> is provides a schema for expressing NFT Metadata within the transaction metadata. So in particular, it specifies using the number <code>721</code> as the transaction metadatum label ( a reference to the Ethereum NFT standard ERC-721 ), and proceeds to specify the rest of the structure. The <code>cardano-cli</code> is capable of converting JSON metadata files into the correct wire format, and attaching it to a transaction (with the hash in the transaction body, so that it cannot be corrupted).</p>

CC BY-SA 4.0
2022-10-12T13:19:24.247Z
2023-05-08T06:21:04.020Z
2023-05-08T06:21:04.020Z
Jared Corduan
<p>I am reading through the haddock documentation to find the way metadata is attached to a transaction. In this documentation <a href="https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger/html/Ledger-Blockchain.html" rel="nofollow noreferrer">(1)</a> we have</p>
<pre><code>data Blockchain = [Block]
data Block = [OnChainTx]
</code></pre>
<p>Where</p>
<p><a href="https://i.sstatic.net/ZQG5U.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZQG5U.png" alt="OnChainTx definition" /></a></p>
<p>and</p>
<p><a href="https://i.sstatic.net/yaftL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yaftL.png" alt="Tx definition" /></a></p>
<p>Now my question is, where and how is metadata appended? My guess is that the only place it could be is in the <code>txData</code> field. And if so, take the example of NFT metadata. By CIP 25 it is of a certain JSON format. Is this than converted via JSON -&gt; <code>data</code> -&gt; <code>BuiltinData</code> and finally wrapped in the <code>Datum</code> type?</p>

CC BY-SA 4.0
2022-04-14T14:21:53.623Z
I think it just not possible to retrieve metadata from the transaction info that is server into a validator script. Perhaps in the future :)
Fermat
CC BY-SA 4.0
2022-04-15T07:14:21.607Z
Also see https://cardano.stackexchange.com/questions/2093/append-metadata-to-transaction-from-plutus-code
Fermat
<plutus-pioneer-program><transaction><ledger><transaction-metadata>
How is metadata typed on the blockchain
# How is metadata typed on the blockchain

(Asked by: username_0 on 2022-04-13)

I am reading through the haddock documentation to find the way metadata is attached to a transaction. In this documentation (1) we have
data Blockchain = [Block]
data Block = [OnChainTx]

Where

and

Now my question is, where and how is metadata appended? My guess is that the only place it could be is in the txData field. And if so, take the example of NFT metadata. By CIP 25 it is of a certain JSON format. Is this than converted via JSON -> data -> BuiltinData and finally wrapped in the Datum type?

**Tags:** plutus-pioneer-program, transaction, ledger, transaction-metadata
> **Comments:**
> **username_0**: I think it just not possible to retrieve metadata from the transaction info that is server into a validator script. Perhaps in the future :)  
> **username_0**: Also see https://cardano.stackexchange.com/questions/2093/append-metadata-to-transaction-from-plutus-code  

---

## 1 answers

### Answer by username_1 on 2022-10-12. Score: 3 | Accepted answer

The transaction metadata lives outside of the transaction body, inside of the `auxiliary_data`. In the Babbage ledger era, you can see this in the wire spec (CDDL)
[here](https://github.com/input-output-hk/cardano-ledger/blob/fc4734c93d60158f2db04b416266268d0261c443/eras/babbage/test-suite/cddl-files/babbage.cddl#L17)
In particular, the metadata is defined
[here](https://github.com/input-output-hk/cardano-ledger/blob/fc4734c93d60158f2db04b416266268d0261c443/eras/babbage/test-suite/cddl-files/babbage.cddl#L329-L337).

In Haskell, you can see that the metadata is
[defined](https://github.com/input-output-hk/cardano-ledger/blob/fc4734c93d60158f2db04b416266268d0261c443/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Data.hs#L241y)
as a map from `Word64` to `Metadatum`.
(I've chosen the Alonzo auxiliary data type to link to here, which is re-used by the Babbage era).

And `Metadatum` is the JSON-like structure defined
[here](https://github.com/input-output-hk/cardano-ledger/blob/fc4734c93d60158f2db04b416266268d0261c443/eras/shelley/impl/src/Cardano/Ledger/Shelley/Metadata.hs#L65-L72).

---

**Note** that the transaction metadata is a different type than the `Datum` type used by Plutus, though the structure is nearly identical. (`txData` contains `Datum`, not `Metadatum`.)

---

[CIP-25](https://cips.cardano.org/cips/cip25/) is provides a schema for expressing NFT Metadata within the transaction metadata. So in particular, it specifies using the number `721` as the transaction metadatum label ( a reference to the Ethereum NFT standard ERC-721 ), and proceeds to specify the rest of the structure. The `cardano-cli` is capable of converting JSON metadata files into the correct wire format, and attaching it to a transaction (with the hash in the transaction body, so that it cannot be corrupted).


---

