Subscribe to our Blog

Subscribe to Crossmint's blog to receive updates on the latest case studies, Web3 technical guides, and more.

Subscribe Crossmint Blog cover image
Rohit Ramesh profile image Rohit Ramesh

How to Create and Mint NFTs on Solana

Learn how to create NFT Collections and mint NFTs on Solana in a few mins using no-code or via API calls. You can also mint NFTs to an email address or a wallet address.

How to Create and Mint NFTs on Solana

In this tutorial, you will learn how to create and mint NFTs on Solana using Crossmint.

By the end, you will learn how to:

This guide will take you 10 mins to complete (approximately).

Let's get started!

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 Solana using 2 simple API calls.

Setup

In this section, you will prepare our development environment for creating and minting NFTs on Solana using Crossmint. You will also be learning the different environments at Crossmint, how to create an API key, and configuring the API key with the necessary.

Difference between Staging and Production

Crossmint has two different environments, they are Staging and Production.

The Staging environment is for testing and development purposes, allowing the use of test credit cards and testnets like Sepolia and Mumbai without real financial transactions or asset risks. Access it via https://staging.crossmint.com.

Conversely, the Production environment is the live setting for real user interactions and transactions, accessed via https://www.crossmint.com. Transactions here occur on mainnets and involve actual financial implications.

Creating a Developer Account and API Key

To integrate Crossmint’s functionalities into your project, you'll need to create an API key. Here's a condensed guide using JavaScript:

  1. Create a Developer Account: Before you proceed, make sure that you have a Crossmint developer account. If not, please sign up - Crossmint Console.
  2. Navigate to API Keys Section: Log into Crossmint's Console and navigate to "Developers" section and click on "API Keys".
  3. Create a New API Key: Click "Create new key" and select "Server-side Key" as the type of key you wish to generate.
  4. Select the Necessary Scopes: Choose scopes relevant to your project needs. For NFT operations, you will need:
    1. "nfts.create"
    2. "nfts.read"
    3. "collections.create"
    4. "collections.read"
Create and Mint NFTs on Solana

Create an NFT Collection on Solana

Before you create and mint NFTs on Solana, you first need to create an NFT Collection on Solana using Crossmint. Let's learn how to do that.

Create a Collection

To create an NFT collection, you'll need to send a POST request to the Crossmint API. Make sure to replace "YOUR_CROSSMINT_API_KEY" with your actual API key and adjust the "metadata" fields according to your collection's specifics.

const axios = require('axios');

// Replace 'YOUR_CROSSMINT_API_KEY' with your actual Crossmint API key
const API_KEY = 'YOUR_CROSSMINT_API_KEY';

// Set up the request headers
const headers = {
    'X-API-KEY': API_KEY,
    'Content-Type': 'application/json',
};

// Define the collection details
const collectionData = {
    chain: "solana",
    metadata: {
        name: "My Solana NFT Collection",
        imageUrl: "https://example.com/my-collection-image.png",
        description: "This is my unique NFT collection on Solana.",
        symbol: "MYSOL"
    },
    fungibility: "non-fungible",
    supplyLimit: 10000 // Adjust the supply limit as needed
};

// API endpoint for creating a collection on Solana
const apiUrl = 'https://www.crossmint.com/api/2022-06-09/collections/';

// Make the request to create the collection
axios.post(apiUrl, collectionData, { headers })
    .then(response => {
        console.log('Collection created:', response.data);
        // Use the action ID from the response for the next step
        const actionId = response.data.actionId;
        // Proceed to verify the collection deployment (Step 2)
    })
    .catch(error => console.error('Error creating collection:', error));

This code snippet sends a POST request to create a new NFT collection on Solana. The response contains an "actionId" which is crucial for the next step.

Verify Collection Deployment

After creating the collection, you'll receive an "actionId" which you can use to check the status of your collection's deployment. Replace "YOUR_ACTION_ID" with the "actionId" obtained from the previous response.

// Replace 'YOUR_ACTION_ID' with the actual action ID obtained from the collection creation response
const actionId = 'YOUR_ACTION_ID';

// API endpoint for checking the action status
const actionStatusUrl = `https://www.crossmint.com/api/2022-06-09/actions/${actionId}`;

// Make the request to check the collection deployment status
axios.get(actionStatusUrl, { headers })
    .then(response => {
        console.log('Deployment status:', response.data);
    })
    .catch(error => console.error('Error checking deployment status:', error));

This snippet checks the status of the collection's deployment on the blockchain by making a GET request using the "actionId". The response will tell you whether the deployment is "pending", "successful", or if there were any errors.

By following these steps, you have successfully created an NFT collection on Solana with Crossmint.

Create and Mint NFTs on Solana

Now that we have created an NFT Collection on Solana, we need to create and mint NFTs onto the collection.

Mint an NFT on the Created Collection

To mint an NFT, you need to have a collection created as outlined in the previous sections. Once you have your collection ID, you can proceed to mint an NFT to a specific recipient (a web3 wallet or an email address). Here is a basic example of how to mint an NFT:

const axios = require('axios');
const collectionId = 'your-collection-id'; // Replace with your actual collection ID
const API_KEY = 'your-crossmint-api-key'; // Replace with your actual Crossmint API key

const mintNFT = async () => {
  const mintData = {
    recipient: "email:test@example.com:solana", // Specify the recipient format
    metadata: {
      name: "Crossmint Example NFT",
      image: "https://www.crossmint.com/assets/crossmint/logo.png",
      description: "My NFT created via the mint API!"
    },
    // Additional options like "reuploadLinkedFiles" can be included based on your needs
  };

  try {
    const response = await axios.post(`https://www.crossmint.com/api/2022-06-09/collections/${collectionId}/nfts`, mintData, {
      headers: {
        'Content-Type': 'application/json',
        'X-API-KEY': API_KEY,
      },
    });

    console.log("Minted NFT action ID:", response.data.actionId);
    return response.data.actionId; // We'll use this to check the status later
  } catch (error) {
    console.error("Error minting NFT:", error.response.data);
  }
};

mintNFT();

This code snippet sends a POST request to the Crossmint API to mint an NFT within the specified collection. We include metadata such as the name, image, and description of the NFT. The recipient is specified in a format recognized by Crossmint, which supports delivery to either a wallet address or an email address.

Verify the NFT was Minted Using the Action ID

After minting the NFT, it's essential to verify that the operation was successful. We can do this by checking the status of the mint operation using the action ID returned in the previous step:

const verifyNFTMint = async (actionId) => {
  try {
    const response = await axios.get(`https://www.crossmint.com/api/2022-06-09/actions/${actionId}`, {
      headers: {
        'X-API-KEY': API_KEY,
      },
    });

    const { status, data } = response.data;
    console.log("Mint action status:", status);
    console.log("NFT data:", data);
  } catch (error) {
    console.error("Error checking mint status:", error.response.data);
  }
};

// Example usage with an action ID
// const actionId = 'your-mint-action-id'; // This would be the action ID returned from the mintNFT function
// verifyNFTMint(actionId);

This function performs a GET request to the Crossmint API using the action ID received from the minting operation. It prints out the status of the minting operation, which can be "pending", "successful", or indicate an error. Additionally, it logs any data associated with the NFT minting operation, providing insights into the minting process and results.

By following these steps and using the provided code snippets, you can create and mint NFTs on Solana using Crossmint's API, offering a seamless integration for NFT creation and distribution.

Extra: You can also create and mint Compressed NFTs (cNFTs) on Solana with 0 using the Crossmint Console:

Mint compressed NFT

Check the next post to know how to do it:

Compressed NFTs Explained | How to Mint cNFTs
Compressed NFTs are the newest NFT standard on Solana, improving scalability and lowering cost to store NFTs on-chain.

Conclusion

Throughout this guide, we've walked you through the steps necessary for setting up your environment on Crossmint, creating an NFT collection on Solana, and minting NFTs onto that collection. You have also learned how to set up your environment to make the required API calls to Crossmint.

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 NFT 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.

Sign up developer console

Related content

Enable Crosschain Payments on Solana | Crossmint
Enable NFT Crosschain payment on Solana via a few simple clicks, and no code required!
How to Create a Solarplex Frame to Mint Compressed NFTs
Learn how to create a Solarplex Frame that allows your users to mint a compressed NFT on the Solana Blockchain directly to their Solana wallet.
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
Rohit Ramesh profile image Rohit Ramesh
DevRel Engineer at Crossmint