Metadata

Overview

On-chain metadata is a powerful feature of the Cardano blockchain that enables storing data within transactions (CIP-25) or datum in UTXOs (CIP-68). The Anvil API provides flexible options for including metadata in your transactions through a streamlined interface.

Metadata serves several key purposes in the Cardano ecosystem:

  • NFT Information (CIP-25, CIP-68): Store details about tokens like name, description, and image links

  • Transaction Messages (CIP-20): Include human-readable messages or technical information such as:

    • Payment references or receipt identifiers

    • Invoice numbers for business transactions

    • Short notes explaining the purpose of transfers

    • DEX transaction identifiers for tracking operations

  • Protocol-specific Data: Support for custom protocols through specialized metadata formats

How Anvil Handles Metadata

The Anvil API processes metadata through the meta array in your transaction payload. Each entry in this array can contain a label and data.

Supported Label Mappings

Anvil supports the following predefined friendly labels that map to Cardano metadata specifications:

Friendly Label
Numeric Label
Purpose

"message"

674

Transaction messages (CIP-20)

"token"

721

NFT metadata (CIP-25, CIP-68)

If you use a friendly label, Anvil will automatically convert it to the corresponding numeric value.

Metadata Structure

Note: You can use the predefined friendly labels above, any numeric label, or no label at all.

You can use the following structure to define metadata in your transaction payload:

Behind the scenes, Anvil employs sophisticated metadata handling with these features:

  • Friendly Labels: Convert human-readable labels to their numeric counterparts (e.g., "token" → 721)

  • Structure Merging: Similar metadata entries are intelligently combined

  • Automatic String Chunking: Long strings exceeding Cardano's 64-byte limit are split into arrays

  • Format Validation: Ensures compliance with Cardano transaction specifications

Example: How Anvil API does Structure Merging

When multiple metadata entries use the same label, Anvil merges them instead of overwriting or duplicating:

This allows you to build complex metadata incrementally from different parts of your application.

Example: How Anvil API does Automatic String Chunking

When a string exceeds Cardano's 64-byte limit, Anvil automatically converts it to an array of shorter strings:

Working with CIP-25 and CIP-68 Metadata (Label 721)

IMPORTANT WARNING: Metadata is only one part of the NFT minting process. For proper CIP-25 and CIP-68 implementation, you should follow the complete minting documentation. Attempting to implement NFT minting by manually constructing transactions with just the metadata structure below will lead to complexity and likely errors. Please refer to the CIP-25 NFT Minting Guide or CIP-68 NFT Minting Guide for the complete implementation.

CIP-25 established the original NFT metadata standard for Cardano, while CIP-68 expanded on this with additional capabilities for evolving NFTs. Most applications support both standards with the following characteristics:

  • Hierarchical Structure: Organized by policy ID and asset name

  • Rich Content Support: Name, description, image, and other media attributes

  • Extensibility: Support for custom attributes beyond the core specification

Note on CIP-68 Implementation: While both CIP-25 and CIP-68 use the same metadata structure under label 721, CIP-68 requires additional implementation steps beyond metadata definition. CIP-68 uses a two-token model (reference NFT label 100 + user token label 222) with the metadata stored in a datum. For complete CIP-68 implementation, see the CIP-68 NFT Minting Guide.

CIP-25 Specification | CIP-68 Specification

Anvil provides three equivalent ways to define CIP-25/CIP-68 metadata:

  1. Using the friendly "token" label

  2. Using the numeric 721 label directly or any other numeric label

  3. Using no label with direct structure

All three approaches result in identical on-chain metadata.

Example

Working with CIP-20 Transaction Messages (Label 674)

CIP-20 defines a standard for including human-readable messages in transactions using label 674. These messages are ideal for providing context, receipts, or references within transactions.

Anvil provides four equivalent ways to define CIP-20 transaction messages:

  1. Using the friendly "message" label - Simplest approach that automatically converts to label 674 on-chain

  2. Using the numeric 674 label directly - Same outcome as the friendly label approach

  3. Using no label with direct structure - Maximum control over the final structure

  4. Using the simplified message property - A special Anvil shorthand that handles all the formatting

All approaches result in correctly formatted message metadata on-chain, with each message appearing as an entry in the msg array under label 674.

Example

Conclusion

The Anvil API provides a flexible system for incorporating metadata in your Cardano transactions:

  • Use the CIP-25/CIP-68 format (label 721) for NFT metadata

  • Use the CIP-20 format (label 674) for transaction messages

  • Choose the definition approach that best fits your workflow - friendly labels or direct numeric labels

In all cases, the resulting on-chain metadata follows the respective CIP standards, ensuring compatibility with wallets, explorers, and applications that interact with the Cardano blockchain.

Further Resources

Mint NFTs (CIP-25)Mint NFTs (CIP-68)

Last updated

Was this helpful?