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:
"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
Working with CIP-25 and CIP-68 Metadata (Label 721)
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
Anvil provides three equivalent ways to define CIP-25/CIP-68 metadata:
Using the friendly
"token"
labelUsing the numeric
721
label directly or any other numeric labelUsing no label with direct structure
All three approaches result in identical on-chain metadata.
Example
Working with CIP-20 Transaction Messages (Label 674)
Anvil provides four equivalent ways to define CIP-20 transaction messages:
Using the friendly
"message"
label - Simplest approach that automatically converts to label674
on-chainUsing the numeric
674
label directly - Same outcome as the friendly label approachUsing no label with direct structure - Maximum control over the final structure
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 metadataUse the CIP-20 format (label
674
) for transaction messagesChoose 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
Last updated
Was this helpful?