Dynamic NFTs are tokens whose content changes over time. There are two ways to achieve this with Crossmint:

  1. Using Crossmint’s Edit NFT API
  2. Storing the metadata offchain and updating it on your database. To use this option, set the property reuploadLinkedFiles to false when minting an NFT.

Using the Edit NFT API

The Edit NFT API allows you to update the metadata of an existing NFT, including its name, description, image, and attributes. This is useful for creating NFTs that evolve over time or need to be updated based on external events.

Prerequisites

  • Ensure your API key is a server-side key with the nfts.update scope
  • You need the collection ID and NFT ID from the minting process

Implementation

cURL
curl --request PATCH \
  --url https://staging.crossmint.com/api/2022-06-09/collections/{collectionId}/nfts/{nftId} \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --data '{
  "metadata": {
    "description": "My updated NFT description!",
    "image": "https://www.crossmint.com/assets/crossmint/updated-image.png",
    "name": "Evolved NFT",
    "attributes": [
      {
        "trait_type": "level",
        "value": "2"
      }
    ]
  },
  "reuploadLinkedFiles": true
}'

Using Off-chain Metadata

You can also store the metadata off-chain and update it directly:

  1. When minting the NFT, set reuploadLinkedFiles to false
  2. Use your own server to host the metadata
  3. Update the metadata on your server as needed
// Example: Minting with off-chain metadata
const apiKey = "YOUR_API_KEY";
const chain = "polygon-amoy"; // or "ethereum-sepolia", "base-sepolia", etc.
const env = "staging"; // or "www" for production
const recipientEmail = "TEST_EMAIL_ADDRESS";
const recipientAddress = `email:${recipientEmail}:${chain}`;

// The URL to your metadata server
const metadataImgUrl = "https://your-server.com/metadata/token123.png";

const url = `https://${env}.crossmint.com/api/2022-06-09/collections/default/nfts`;
const options = {
    method: "POST",
    headers: {
        accept: "application/json",
        "content-type": "application/json",
        "x-api-key": apiKey,
    },
    body: JSON.stringify({
        recipient: recipientAddress,
        metadata: {
            name: "Dynamic NFT",
            description: "This NFT will update over time",
            image: metadataImgUrl,
        },
        reuploadLinkedFiles: false,
    }),
};

fetch(url, options)
    .then((response) => response.json())
    .then((data) => console.log(data))
    .catch((error) => console.error("Error:", error));

Use Cases for Dynamic NFTs

Dynamic NFTs enable a wide range of applications:

  • Game Assets: NFTs that evolve as players progress
  • Membership Passes: NFTs that update based on membership status
  • Event Tickets: NFTs that change before, during, and after events
  • Digital Collectibles: NFTs that evolve based on real-world events
  • Loyalty Programs: NFTs that update based on customer activity

Best Practices

When implementing dynamic NFTs:

  1. Plan for Updates: Design your NFT with future updates in mind
  2. Versioning: Consider including version information in your metadata
  3. Event Triggers: Define clear conditions for when updates should occur
  4. User Communication: Inform users about how and when their NFTs might change
  5. Testing: Thoroughly test update mechanisms before implementation

FAQs