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]


OnChainTx definition


Tx definition

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?

  • 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
    Commented Apr 14, 2022 at 14:21
  • Also see cardano.stackexchange.com/questions/2093/…
    – Fermat
    Commented Apr 15, 2022 at 7:14

1 Answer 1


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 In particular, the metadata is defined here.

In Haskell, you can see that the metadata is defined 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.

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 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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.