Rohit Ramesh profile image Rohit Ramesh

How to Create and Mint NFTs on Base

Learn how to create NFT Collections and mint NFTs on Base in a few mins using only simple API calls. You can also mint NFTs to an email address or a wallet address.

How to Create and Mint NFTs on Base

In the ever-evolving world of digital assets, creating and minting Non-Fungible Tokens (NFTs) stand as a beacon of innovation and opportunity.

This tutorial is designed to guide you through the seamless integration of Crossmint and Base, two powerhouse platforms that revolutionize the way we interact with blockchain technology.

Crossmint facilitates the development and distribution of digital assets with unparalleled ease, while Base offers a cost-effective, secure environment for on-chain applications. Together, they enable a straightforward path to creating and minting NFTs without getting bogged down in technical complexities. Completing this walkthrough will take approximately 30 minutes, equipping you with the knowledge to embark on your NFT creation journey efficiently.

Let's dive into the transformative world of NFTs with Crossmint and Base, unlocking the full potential of blockchain technology for your digital endeavors.

Table of Contents:


Create and Mint NFTs with No-code

If you are wondering how you can create an NFT Collection and mint NFTs with no-code, please read the in-depth guide linked below that teaches you how to do this with 0 code.

How to Create an NFT Collection and Mint NFTs with 0 Code
In under 10 mins, learn how to create NFT Collections, create and mint NFTs with no-code.

However, the rest of this guide will show you how you can create NFT Collections and mint NFTs on Base using 2 simple API calls.

Setup

Getting started with creating and minting NFTs on Base using Crossmint involves understanding the fundamental distinction between staging and production environments, creating an API Key, and knowing the scopes necessary for your API key.

Difference between Staging and Production

When working on web applications and platforms like Crossmint, it's essential to distinguish between the staging and production environments.

The staging environment serves as a test bed, mimicking the production setup without affecting the live version. It's accessible via https://staging.crossmint.com and allows developers to deploy and test their features in a risk-free setting. Conversely, the production environment, found at https://www.crossmint.com, is where the live, user-facing application resides. Changes here are public and have real-world implications.

Creating a Developer Account and API Key

Creating an API key is crucial for integrating Crossmint functionalities within your app, especially for server-side operations like NFT minting. Follow these steps:

  1. Verify Developer Account: Ensure you have a Crossmint developer account. Sign up at Crossmint Console if you haven't already.
  2. Navigate to API Keys Section: Log into the Crossmint Console and locate the "API Keys" section, usually under settings or a direct tab.
  3. Choose the Type of API Key: Opt for a Server-side API Key required for operations like NFT collection creation or minting.
  4. Select Scopes: When prompted, select scopes that determine the API key’s access level. Essential scopes include "nfts.create", "nfts.read", "collections.create", "collections.update", and "collections.read" to create NFT Collections and create NFTs.
Create and Mint NFTs on Base

Required Scopes for the API Key

For creating NFT collections and minting NFTs on Base using Crossmint, ensure your API key includes the following scopes:

  • "collections.create"
  • "collections.read"
  • "nfts.create"
  • "nfts.read"

These scopes allow you to not only create and read NFT collections but also to create and read the NFTs themselves. Appropriately setting up your API key is foundational for successful integration with Crossmint’s services.

Understanding and setting up the environment, along with creating an appropriately scoped API key, are the initial critical steps for developers. These enable seamless creation and minting of NFTs using Crossmint, paving the way for integrating blockchain functionalities into your Base projects.

Create an NFT Collection on Base

To kick-start your journey of launching a unique NFT collection on Base, you need to begin by creating the collection itself. This process involves preparing the collection's metadata and deploying it to the blockchain. Let's walk through the steps to accomplish this using Crossmint's API.

Prepare Your Collection's Metadata

The first step is to define the characteristics of your NFT collection. This includes the name, image URL representing the collection, a description, and the collection symbol (for EVM only). Here's an example of how to prepare this metadata:

const collectionMetadata = {
  chain: "base", // Specify 'base' for the Base blockchain
  metadata: {
    name: "My Unique NFT Collection", // Your collection's name
    imageUrl: "https://www.example.com/collection-image.png", // URL of the collection's representative image
    description: "A collection of unique digital assets.", // Description of your collection
    symbol: "UNQ" // Collection symbol (EVM chains only)
  },
  fungibility: "non-fungible", // Specify whether the collection is non-fungible or semi-fungible
  supplyLimit: 1000, // The maximum number of NFTs in the collection
  payments: {
    price: "0.01", // Price per NFT in the native currency
    recipientAddress: "0xYourWalletAddress" // Your wallet address to receive payments
  },
  reuploadLinkedFiles: true // Indicates if URLs in metadata should be reuploaded to IPFS
};

Make sure to replace the placeholders ("https://www.example.com/collection-image.png" and "0xYourWalletAddress") with your actual collection image URL and recipient wallet address.

Create the NFT Collection

With the metadata ready, you can now proceed to create the collection by making a POST request to the Crossmint API. Ensure you've obtained your API key from the Crossmint developer console and have it readily available.

const axios = require('axios'); // Ensure you have axios installed

const createCollection = async (metadata) => {
  const API_URL = "https://www.crossmint.com/api/2022-06-09/collections/";
  const API_KEY = "your_api_key_here"; // Replace with your actual Crossmint API key
  
  try {
    const response = await axios.post(API_URL, metadata, {
      headers: {
        "X-API-KEY": API_KEY,
      },
    });
    
    console.log("Collection created successfully:", response.data);
    return response.data; // This includes the collection ID and action ID
  } catch (error) {
    console.error("Failed to create collection:", error.response.data);
  }
};

createCollection(collectionMetadata).then((data) => {
  console.log("Created Collection ID:", data.id);
  console.log("Deployment Action ID:", data.actionId);
});

This script makes a POST request to the Crossmint API to create your NFT collection. Upon success, it logs the collection ID and the action ID, which is important for tracking the deployment status.

Verify Deployment Status

After creating your collection, you should verify that it has been deployed successfully on the blockchain. You can do this by polling for the status of the deployment action using the action ID returned in the previous step.

const ACTION_ID = "your_action_id_here"; // Replace with your actual action ID

const checkDeploymentStatus = async (actionId) => {
  const API_URL = `https://www.crossmint.com/api/2022-06-09/actions/${actionId}`;
  
  try {
    const response = await axios.get(API_URL, {
      headers: {
        "X-API-KEY": API_KEY,
      },
    });
    
    console.log("Deployment Status:", response.data.status);
    return response.data.status; // This is the status of your collection's deployment
  } catch (error) {
    console.error("Failed to check deployment status:", error.response.data);
  }
};

checkDeploymentStatus(ACTION_ID).then((status) => {
  if (status === "success") {
    console.log("Your collection has been deployed successfully!");
  }
});

Replace "your_action_id_here" with the actual action ID you received from creating the collection. This script will check the status of the deployment and log whether it has been successfully deployed to the blockchain.

Following these steps will successfully create your NFT collection on Base using the Crossmint API. The collection is now ready for minting NFTs, which we will cover in the next section.

Create and Mint NFTs on Base

In this section, we’ll go through the steps required to create and mint your own NFTs on the Base blockchain using the Crossmint API. We assume you've already created a collection as detailed in the previous section.

Mint an NFT on the Created Collection

To mint an NFT, you will use the collection ID of the collection you created. You'll specify metadata for your NFT, which includes a name, image, and description, and the recipient information.

First, ensure you have the "collectionId" from the collection creation step. Then, prepare your NFT metadata and recipient details. Here's how you can do it in JavaScript:

const axios = require('axios');
const apiKey = 'YOUR_CROSSMINT_API_KEY';
const collectionId = 'YOUR_COLLECTION_ID'; // Replace with your actual collection ID
const nftMetadata = {
  name: "Crossmint Example NFT",
  image: "https://www.crossmint.com/assets/crossmint/logo.png",
  description: "My NFT created via the mint API!"
};
const recipient = "email:testy@crossmint.io:base"; // Example recipient format

axios.post(`https://www.crossmint.com/api/2022-06-09/collections/${collectionId}/nfts`, {
  recipient,
  metadata: nftMetadata
}, {
  headers: {
    'X-API-KEY': apiKey
  }
})
.then(response => {
  console.log("Mint Response:", response.data);
})
.catch(error => {
  console.error("Error minting NFT:", error);
});

In this code snippet, you replace "YOUR_CROSSMINT_API_KEY" with your actual API key and "YOUR_COLLECTION_ID" with the collection ID you received from creating your NFT collection. The recipient in this example uses an email and chain format, but you can replace it with a direct wallet address if preferred.

Replace the email address with the target email address that you want to mint the NFT to.

Verify the NFT was Minted Using the Action ID

After minting your NFT, you'll receive an actionId in the response. You can use this ID to check the status of the minting process. Below is how you can poll for the minting status:

const actionId = 'YOUR_ACTION_ID_FROM_MINTING'; // Replace with your actual action ID

const checkMintingStatus = () => {
  axios.get(`https://www.crossmint.com/api/2022-06-09/actions/${actionId}`, {
    headers: {
      'X-API-KEY': apiKey
    }
  })
  .then(statusResponse => {
    console.log("Minting Status:", statusResponse.data);
    if(statusResponse.data.status !== 'completed') {
      console.log("Minting in progress, check back later.");
    } else {
      console.log("Minting completed successfully.");
    }
  })
  .catch(error => {
    console.error("Error checking minting status:", error);
  });
}

// Initial check
checkMintingStatus();

// Optionally, set an interval to poll periodically
// setInterval(checkMintingStatus, 60000); // Check every 60 seconds

Replace "YOUR_ACTION_ID_FROM_MINTING" with the action ID you received from the minting response. This script first makes an immediate check on the minting status and logs the result. Optionally, you can enable the "setInterval" line to have it check periodically until the minting is confirmed as completed.

By following these steps and using the provided code snippets, you can mint your own NFTs onto your collection on the Base blockchain using the Crossmint API. This process leverages the power of blockchain technology to create unique digital assets, seamlessly integrating them into your applications or platforms.

Conclusion

In this guide, we explored the steps necessary to create and mint NFTs on Base, starting from setting up an API key with the appropriate scopes to creating a collection and minting NFTs within it. By following the outlined procedures, you've seen how straightforward it can be to deploy a collection and then populate it with unique digital assets. Whether you're looking to mint NFTs for fun, for a project, or to learn more about the blockchain space, this tutorial provided a solid foundation. Remember, the key to mastering NFT creation and minting lies in experimentation and continued learning.

What's Next?

If you are wondering how Crossmint has helped enterprises and brands by powering their NFT Drops, you can click on the link below to read all our Case Studies.

Case Studies
Access 25+ case studies, across industries, from the 30,000+ companies that have used Crossmint’s infrastructure.

If you want to learn how to use the Crossmint to create Web 3 Wallets for your users using their Email Address, please watch the YouTube video below.

Need help?

For support, please join the official Crossmint Discord Server. You can also use Crossmint Help Page for the same.

Enabling NFT Cross Chain Payment on Ethereum Layer 2
This guide will show you how to enable cross chain payment on Ethereum Layer 2s such as Base or Optimism with Solana and Ethereum on mainnet.
Create an NFT Storefront with 0 Code | Crossmint
With Crossmint’s No-Code Storefronts, you can start selling NFTs right now, with cross-chain and credit card payments automatically activated
Sign up developer console
Rohit Ramesh profile image Rohit Ramesh
DevRel Engineer at Crossmint