Understanding Cardano NFTs and CIP-68

Hey there! Let’s talk about something exciting happening with NFTs on Cardano. I’ll break down CIP-68 and show you exactly how it works - don’t worry, I’ll keep it simple! 😊

What Makes CIP-68 Special?

Think of CIP-68 like having two connected parts to your NFT:

  • A behind-the-scenes part that can be updated (reference token)
  • The NFT you actually own and can trade (user token)

It’s like having a trading card where the picture stays the same, but the stats can be updated. Cool, right?

How Does It Actually Work? 🛠️

Let me show you the basics:

  1. The Token Pair
NFT = Reference Token (updatable info) + User Token (what you own)
  1. How They’re Created
Reference Token = Policy ID + Asset Name + 00
User Token = Policy ID + Asset Name + 01

The clever part is how they work together:

  • The Reference Token (ends in 00) stores all the updatable information
  • The User Token (ends in 01) is what you actually own and trade
  • They’re always linked together through their matching Policy ID and Asset Name

For example, if you have a gaming sword NFT:

  • Reference Token: Stores the sword’s current level, damage stats, special powers
  • User Token: Shows that you own this specific sword

Real Examples You’ll Love 🎮

  1. Gaming: Your sword starts at Level 1. As you play:

    • The Reference Token updates with new stats
    • Your User Token stays the same - proving it’s your sword
    • The sword gets stronger but stays uniquely yours!
  2. Digital Art: An artist creates evolving artwork:

    • Reference Token: Can update the artwork’s appearance
    • User Token: Proves you own this piece
    • The art can change while your ownership stays secure
  3. Memberships: Like a smart membership card:

    • Reference Token: Updates with your current benefits
    • User Token: Shows you’re the member
    • Benefits can change without issuing new cards

Let’s Read Some Real NFT Data! 💻

Want to see how this works in real life? Let’s look at how to read NFT data from SpaceBudz, a popular Cardano NFT project:

// Helper function to read datum from SpaceBudz NFT
const getSpaceBudzDatum = async (assetName) => {
  // Get reference token name (append '00' for CIP-68 reference)
  const refTokenName = assetName + '00';
  
  // Construct the query to read datum
  const query = {
    "query": `
      query GetDatum {
        transactions(
          where: {
            outputs: {
              tokens: {
                asset: { nameHex: { _eq: "${refTokenName}" } }
              }
            }
          }
          order_by: { block: { number: desc } }
          limit: 1
        ) {
          outputs {
            datum {
              value
            }
          }
        }
      }
    `
  };

  // Use Koios or BlockFrost API to execute query
  const response = await fetch('BLOCKFROST_OR_KOIOS_ENDPOINT', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'project_id': 'YOUR_API_KEY'
    },
    body: JSON.stringify(query)
  });

  const data = await response.json();
  return data;
}

// Usage example
const nftData = await getSpaceBudzDatum('SpaceBud123');
console.log('NFT Metadata:', nftData);

When you run this code, you’ll get something like this:

{
  "reference": {
    "version": 1,
    "name": "SpaceBud #123",
    "image": "ipfs://QmXxxx...",
    "attributes": {
      "gadget": "Laser Gun",
      "type": "Alien",
      "rarity": "Rare"
    }
  },
  "user": {
    "owner": "addr1qxxx...",
    "locked": false
  }
}

Pro tip: Remember to replace 'BLOCKFROST_OR_KOIOS_ENDPOINT' and 'YOUR_API_KEY' with actual values! 😉

The Cool Benefits 🌟

This system makes NFTs:

  • Cheaper to store (less blockchain space needed)
  • More flexible (can be updated)
  • Better for apps and games
  • Still secure and truly yours

What’s Next? 🚀

More and more projects are using CIP-68 because it makes NFTs more useful and fun. Whether you’re an artist, gamer, or collector, these “smart NFTs” open up exciting new possibilities!

Have you tried any NFTs using CIP-68? I’d love to hear about your experience! Drop a comment below and let’s chat about it. 😊

Remember: The NFT world moves fast, and this is just the beginning of what’s possible on Cardano! ^^