• Home
  • Guides
  • How to Create and Mint NFTs on Solana
How to Create and Mint NFTs on Solana
By Rohit Ramesh profile image Rohit Ramesh
8 min read

How to Create and Mint NFTs on Solana

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

Welcome to our step-by-step tutorial on creating and minting Non-Fungible Tokens (NFTs) on the Solana blockchain, leveraging the powerful and user-friendly Crossmint platform.

In this guide, we'll walk you through the process of integrating blockchain assets into your applications with ease, even if you're new to the world of cryptocurrencies and blockchain technology.

Crossmint simplifies the complexities of the blockchain, making the technology accessible to all, while Solana ensures your NFT transactions are fast and cost-effective. Whether you're a developer looking to dive into the NFT space or an enterprise aiming to streamline digital asset management, this tutorial is tailored for you.

Completing this tutorial will take you approximately 5 minutes, offering you a quick yet comprehensive understanding of NFT creation and minting on Solana with Crossmint.

Table of Contents:


Setup

In this section, we will prepare our development environment for creating and minting NFTs on Solana using Crossmint. This involves understanding the distinction between staging and production environments, generating an API key, and configuring the necessary scopes for our project.

Difference between Staging and Production

Crossmint provides two environments for developers: 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. Verify Your Developer Account: Ensure you have an active Developer Account with Crossmint. Sign up or log in at the Crossmint Console.
  2. Navigate to API Keys Section: Within the console dashboard, locate and click on the "API Keys" section.
  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 "nfts.create", "nfts.read", "collections.create", "collections.update", and "collections.read".
  5. Store Your API Key Securely: Upon creation, ensure you store your API key securely, avoiding exposure in client-side code or public repositories.

Required scopes for the API key

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

  • "nfts.create": Allows for the creation of NFTs.
  • "nfts.read": Necessary for retrieving NFT details.
  • "collections.create": Required to create new NFT collections.
  • "collections.update" and "collections.read": Enables updating and reading collection details, respectively.
Create and Mint NFTs on Solana

By setting up your environment according to these steps, you'll be well prepared to start creating and minting NFTs on Solana with Crossmint.

Create an NFT Collection on Solana

Creating an NFT collection on Solana using the Crossmint API involves a couple of steps. First, you initiate the creation of the collection, then you check the status of the deployment using the action ID provided in the response. Below are the steps and code examples to guide you through this process.

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

In this section, we'll dive into how to mint NFTs on Solana using the Crossmint API. This process involves two main steps: creating an NFT on your previously setup collection and then verifying that the NFT has indeed been minted successfully. We'll walk through each step with JavaScript code snippets and explanations.

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 your Solana NFTs with 0 code by using our developer 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 to that collection. By following the straightforward steps provided, from obtaining your API key with the right scopes to verifying your minted NFTs using action ids, you have learned the essentials for launching your digital assets on the Solana blockchain. This process demonstrates how seamlessly and efficiently you can create and distribute NFTs, setting a solid foundation for further exploration and creation in the dynamic world of blockchain and digital art.

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
Get in touch for end-to-end tailored solutions with our specialized team. Design your enterprise-grade web3 NFT project with us!

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
By Rohit Ramesh profile image Rohit Ramesh
Updated on
Guides