Mint NFTs (CIP-25)

Overview for minting CIP-25 compliant NFTs/Native Assets on Cardano using the Anvil API's `transactions/build` endpoint. This document specifies the required JSON format for both new and existing poli

Introduction

The transactions/build endpoint using the mint type allows for the creation of unique digital assets (NFTs/Native Assets) following the CIP-25 metadata standard. This guide demonstrates how to structure API requests when working with the Anvil platform to mint these assets, whether you're establishing a new collection or adding to an existing one.

CIP-25 Mint with New Policy

Prerequisites

Before minting a new NFT collection, ensure you have the following:

  1. A valid ADA wallet address (change address)

  2. A list of UTXOs (Unspent Transaction Outputs) from your wallet. See UTXOs

  3. A unique asset name (UTF-8 or hex format)

  4. Custom metadata for your NFT (Use https://metadraft.io to generate accurate metadata easily.)

  5. A native script registered on the Cardano blockchain. (See Creating Native Scripts for more information.)

For more information about native scripts, please see:

Native Scripts

Request Structure

Payload

{
  // Specifies which address should receive any leftover ADA (change) 
  // after the transaction is completed and fees are paid
  "changeAddress": "addr_test1qqwadht4defe...",

  // An array of UTXO strings from the wallet paying for the transaction.
  "utxos": ["8282...", "8282..."],

  // An array of assets to be minted.
  "mint": [
    {
      "version": "cip25",
      // UTF-8 or hex format - Must be unique within the collection.
      "assetName": { "name": "anvilapicip25", "format": "utf8" },

      // Custom Metadata for your NFT. Replace with your own CIP-25 standard values.
      // Use https://metadraft.io to generate accurate metadata easily.
      "metadata": {
        "name": "YOUR_NFT_NAME_HERE",
        "image": [
          "https://your-storage-provider.com/", // URL to your image
          "image-file.png" // File name of your image
        ],
        "mediaType": "image/png", // Media type of your image
        "description": "Anvil API CIP-25 Mint Example" // Description of your NFT
      },
      // The policy ID of the collection.
      "policyId": "4d5bd6249f0d9e4b2762ce334e2973dc7fd414ec1e08b4b0c2159bfb",
      "quantity": 1 // Accepts integers > 0. Negative numbers will burn assets.
    }
  ],

  // An array of native scripts that represent the policy that needs to be pre-loaded for validation.
  // This is required for the initial mint. once the policy is registered this is optional.
  // Including it saves resources and reduces latency by avoiding blockchain fetches.
  "preloadedScripts": [
    {
      "type": "simple",
      // The native script details.
      "script": {
        "type": "all",
        "scripts": [
          {
            "type": "sig",
            "keyHash": "fdf151b600df2492005221876c7d7e33056496572c7363c33a1e3609"
          },
          {
            "type": "before",
            "slot": 100000000
          }
        ]
      },
      // The hash of the native script, which is the Policy ID.
      "hash": "4d5bd6249f0d9e4b2762ce334e2973dc7fd414ec1e08b4b0c2159bfb"
    }
  ]
}

Examples

In order to reduce page content, the use cases and examples are split into a dedicated repository.

Troubleshooting

Fixes and Best Practices

  1. Use the metadata generation tool to ensure your metadata follows the CIP-25 standard

  2. For multiple assets under the same policy, ensure each asset name is unique

  3. Double-check that your time constraints in your native script have not expired

Specifications

Last updated

Was this helpful?