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)
In particular, the metadata is defined
In Haskell, you can see that the metadata is
as a map from
(I've chosen the Alonzo auxiliary data type to link to here, which is re-used by the Babbage era).
Metadatum is the JSON-like structure defined
Note that the transaction metadata is a different type than the
Datum type used by Plutus, though the structure is nearly identical. (
CIP-25 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).