Rohit Ramesh profile image Rohit Ramesh

How to Create and Mint NFTs on Binance Smart Chain

Learn how to create NFT Collections and mint NFTs on Binance Smart Chain 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 Binance Smart Chain

In the fast-evolving digital landscape, the creation and distribution of NFTs (Non-Fungible Tokens) have opened up new avenues for creators and enterprises alike.

This tutorial aims to guide you through the process of creating and minting NFTs on one of the most efficient and cost-effective blockchain networks today, the Binance Smart Chain (BSC).

Leveraging the advanced features of Crossmint, a platform that streamlines the integration of blockchain assets into applications without the prerequisite blockchain knowledge, this guide will simplify your journey into the world of NFTs. BSC, known for its high performance and low transaction costs, complements Crossmint’s capabilities by offering a robust environment for NFTs.

From start to finish, expect to complete this tutorial in under 30 minutes, embarking on a straightforward path to effectively deploying your digital assets.

Table of Contents:

Setup

Before diving into the NFT creation and minting process on Binance Smart Chain (BSC) using Crossmint, it's crucial to understand the different environments available for developers and how to properly set up an API key. These initial steps lay the foundation for a seamless development experience.

Difference between Staging and Production

Crossmint provides two environments for developers: staging and production. The staging environment is designed for testing and development purposes. It's a replica of the production environment but doesn’t handle real transactions. Here, test credit cards are used, and it connects to testnets allowing for free API testing without actual blockchain costs. The staging URL is https://staging.crossmint.com.

The production environment, available at https://www.crossmint.com, is the live environment where real transactions occur. It demands actual credit card payments and interacts with the mainnet blockchains. Both environments require distinct API keys for interaction.

Creating a Developer Account and API Key

  1. Ensure a Developer Account is Active: Visit the Crossmint Console to set up a developer account if you haven't already. This is necessary to access API key management.
  2. Navigate to API Keys: In your Crossmint Console, locate the “API Keys” section. This is where all API key operations are managed.
  3. Generate a New Key: Click on “Create new key” to initiate a new API key. It's recommended to generate a server-side key for backend operations to ensure security.
Create and Mint NFTs on Binance Smart Chain

Required Scopes for the API Key

For tasks involving creating a collection and minting NFTs on BSC, your API key should be configured with specific permissions. Essential scopes include:

  • "nfts.create": Allows for the creation of NFTs.
  • "nfts.read": Necessary for retrieving NFT details.
  • "collections.create": Required to create new NFT collections.
  • "collections.read": To read the collection details.

It's important to store the API key securely and use it appropriately within your application to authenticate and authorize operations against Crossmint services. Remember, staging and production environments require separate API keys to ensure the correct application behavior and data integrity across development and live operations.

Create an NFT Collection on BSC

Creating an NFT collection on the Binance Smart Chain (BSC) through Crossmint involves a few steps, including setting up your collection details and deploying it to the blockchain. Below, we'll cover how to create a collection, then verify that it was deployed successfully using the action ID returned by the API.

Create a Collection

To start, ensure you have your API key ready, obtained from the Crossmint developer console, and choose whether you're working in the staging environment for testing or the production environment for live deployments. For this example, we'll use the production environment.

Here's how you create a collection on BSC:

const axios = require('axios');

async function createCollection() {
  const url = 'https://www.crossmint.com/api/2022-06-09/collections/';
  const apiKey = 'YOUR_API_KEY_HERE'; // Replace with your actual API key
  const data = {
    chain: 'bsc', // Blockchain to use
    metadata: {
      name: 'My Awesome NFT Collection',
      imageUrl: 'https://example.com/my-collection-image.png',
      description: 'This is a collection of my awesome NFTs',
      symbol: 'AWSM' // Symbol for your collection
    },
    fungibility: 'non-fungible', // This collection is non-fungible
    supplyLimit: 1000, // Max supply of tokens in the collection
    payments: {
      price: '0.01', // Price per token in the native currency (e.g., BNB for BSC)
      recipientAddress: '0xYourWalletAddress' // Your wallet address to receive payments
    },
    reuploadLinkedFiles: true // Reupload linked files to IPFS
  };

  const config = {
    headers: {
      'X-API-KEY': apiKey
    }
  };

  try {
    const response = await axios.post(url, data, config);
    const { id, actionId } = response.data;
    console.log(`Collection Created. ID: ${id}, Action ID: ${actionId}`);
    return { collectionId: id, actionId };
  } catch (error) {
    console.error('Error creating collection:', error.response.data);
  }
}

After executing the code above, you'll receive an ID for your newly created collection and an action ID to track the deployment process. It's essential to note the action ID, as it will be used to verify if the collection was deployed successfully.

Verify Collection Deployment Using the ActionID

Once you've received an action ID, you can check the status of your collection deployment. The process may take a minute or more, depending on the current congestion of the blockchain.

async function verifyCollectionDeployment(actionId) {
  const url = `https://www.crossmint.com/api/2022-06-09/actions/${actionId}`;
  const apiKey = 'YOUR_API_KEY_HERE'; // Replace with your actual API key

  const config = {
    headers: {
      'X-API-KEY': apiKey
    }
  };

  try {
    const response = await axios.get(url, config);
    const { status, data } = response.data;
    console.log(`Collection Deployment Status: ${status}`);
    if (status === 'success') {
      console.log('Collection successfully deployed. Contract Address:', data.collection.contractAddress);
    } else if (status === 'pending') {
      console.log('Collection deployment is still pending. Please check back later.');
    } else {
      console.log('Collection deployment failed.');
    }
  } catch (error) {
    console.error('Error checking collection deployment status:', error.response.data);
  }
}

This snippet polls the status of the collection deployment using the provided action ID. If the status is "success", it means the collection has been deployed to BSC, and you'll receive the contract address of your NFT collection. This contract address is crucial for minting NFTs to your collection in future steps.

By following these steps, you've successfully created an NFT collection on the Binance Smart Chain using Crossmint's API.

Create and Mint NFTs on BSC

Once your NFT collection is successfully deployed on the Binance Smart Chain (BSC), the next exciting step is to create and mint NFTs within this collection. This section guides you through minting an NFT on the BSC network and verifying its minting status using the action id provided by Crossmint.

Mint an NFT on the Created Collection

To mint an NFT, you need to make a POST request to the Crossmint API. Ensure to replace "YOUR_API_KEY" with your actual API key and "COLLECTION_ID" with the id of the collection where you intend to mint the NFT.

const axios = require('axios');
const collectionId = 'YOUR_COLLECTION_ID'; // Replace with your actual collection ID
const apiKey = 'YOUR_API_KEY'; // Replace with your Crossmint API key

const mintNFT = async () => {
  const url = `https://www.crossmint.com/api/2022-06-09/collections/${collectionId}/nfts`;

  try {
    const response = await axios.post(url, {
      recipient: "email:testy@crossmint.io:bsc", // Specify recipient
      metadata: {
        name: "Crossmint Example NFT",
        image: "https://www.crossmint.com/assets/crossmint/logo.png",
        description: "My NFT created via the mint API!"
      },
    }, {
      headers: {
        'X-API-KEY': apiKey,
      }
    });

    console.log("NFT Minted: ", response.data);
    return response.data; // This contains the action ID needed to verify the mint
  } catch (error) {
    console.error("Error minting NFT: ", error.response.data);
  }
};

mintNFT();

In the request body, the "recipient" field specifies the recipient of the NFT. The format supports direct blockchain addresses or associating the minted NFT with an email. The "metadata" object contains details about the NFT, such as its name, image, and a brief description.

Verify the NFT was Minted Using the Action Id

After making the minting request, Crossmint provides an "actionId" as part of the response. This ID is essential for tracking the minting process. To verify the status of your NFT minting, execute the following command:

const actionId = 'YOUR_ACTION_ID'; // Replace with the action ID from mintNFT response

const verifyNFTMint = async (actionId) => {
  const url = `https://www.crossmint.com/api/2022-06-09/actions/${actionId}`;

  try {
    const response = await axios.get(url, {
      headers: {
        'X-API-KEY': apiKey,
      }
    });

    console.log("Mint Status: ", response.data);
  } catch (error) {
    console.error("Error getting mint status: ", error.response.data);
  }
};

verifyNFTMint(actionId);

Replace "YOUR_ACTION_ID" with the action ID received from the minting request. The response provides the status of your action, which includes details about the minted NFT, such as the collection ID, recipient wallet address, and the token ID.

This command allows you to track the minting process and ensure that your NFT has been successfully minted and is ready for distribution or sale.

By following these steps, you have successfully created and minted an NFT on the Binance Smart Chain using the Crossmint platform.

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

Conclusion

In this guide, we walked through the process of creating and minting NFTs on the Binance Smart Chain (BSC) using Crossmint. We've covered the crucial steps from setting up your developer environment in staging and production, creating an API key with the necessary scopes, establishing an NFT collection, and finally minting NFTs within that collection. By now, you should have a clear understanding of how to deploy and verify NFTs on BSC, marking your entry into the blockchain world.

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.

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