Create your First NFT collection and Mint Tokens

Part 1 of the complete NFT tutorial series for deploying, minting, transferring, and listing NFTs.

Do you wish to deploy your own NFT token, mint NFTs, sell them on one of the leading marketplaces, or create your own NFT marketplace without knowing the underlying concept?

You are at the right place. In this tutorial, we will discuss end-to-end steps to create your NFT token with easy-to-use REST APIs in a fraction of the time; no need to learn solidity or node infrastructure; just learn a few API calls, and you are all set to go.

MetaKeep NFT Infrastructure

MetaKeep Enterprise NFT infrastructure allows you to fully customize your NFT contract and mint NFTs at scale:

  • NFT contract follows OpenZeppelin ERC721 standard and is fully compatible with OpenSea.

  • You can customize the contracts by setting up the royalty percentage, updating metadata, updating the fee receiver, and much more.

  • Completely owned by you and you only, so you have complete control over the smart contract.

  • You can Mint NFTs at scale on EVM-compatible blockchains like Polygon.

  • You and your users do not need to worry about the gas fees; you can pay us in USD.

Getting Started with MetaKeep NFT Contract

The first step is to get an API key; to do so, sign up here and copy your API key.

You can find an end-to-end working demo here.

Create your NFT collection

We will begin with creating a collection supported by some popular marketplaces like Open sea without writing any solidity code.

Step 1: Create a request with the following parameters

{
    "nft": {
        "name": < NFT Collection Name >,
        "symbol": < NFT Collection Symbol >
    },
    "metadata": {
        "name": < Name of the NFT collection>,
        "description": <Description of NFT collection>,
        "image": < NFT Collection Image>,
        "external_link": <URL of NFT collection>,
        "seller_fee_basis_points": < Royalty fee in basis points for secondary sales>,
        "fee_recipient": < Address to which royalty fees would be paid to>
    }
}

Step 2: Make a POST request to nft/createCollection API

const options = {
    method: 'POST',
    headers: {
        accept: 'application/json',
        'content-type': 'application/json'
    },
    body: JSON.stringify({
        nft: {
            name: "Metakeep_NFT",
            symbol: "MTKNFT",
        },
        metadata: {
            name: "Metakeep_NFT",
            description: "Metakeep_NFT",
            image: "https://metakeep.xyz/images/MetaKeep-1.png",
            external_link: "https://metakeep.xyz",
            seller_fee_basis_points: 1000,
            fee_recipient: "0xa6D88EB4d2e1DD819019ccC13712992f98BABDB9",
        },
    })
};

fetch('https://api.metakeep.xyz/v2/app/nft/createCollection', options)
    .then(response => response.json())
    .then(response => console.log(response))
    .catch(err => console.error(err));

This is what you should see as the API response.

{
  status: 'QUEUED',
  transactionId: 'c95a109b-32ad-4c87-921f-4759d046f517',
  transactionHash: '0xbeb491b36c971d958c51a10f0c51758a248ad82e18caa51069666f5943a823f4',
  transactionChainScanUrl: 'https://mumbai.polygonscan.com/tx/0xbeb491b36c971d958c51a10f0c51758a248ad82e18caa51069666f5943a823f4',
  collection: '0xe4b8d2b9de9da98c57ae82d7cbd18f3574707a50'
}

πŸ“˜

Copy the collection address

Note the collection field in the response above. This is your NFT contract address. Copy this for the next step.

If you have lost the collection address, you can make a request to the List Collections API to get the list of all created collections.

Mint an NFT token

Now let's mint a token inside the collection and issue it to a user.

Step 1: Create a request with the following parameters

{
    "nft": {
        "collection": <Collection address>
    },
    "to": <Mint token to this user. Can be an email or eth address>,
    "metadata": <Token metadata>
}

Step 2: Make a post request to the nft/mint API

const options = {
    method: 'POST',
    headers: {
        accept: 'application/json',
        'content-type': 'application/json'
    },
    body: JSON.stringify({
        to: {
            email: '[email protected]'
        },
        metadata: {
            name: 'Kittie #1',
            description: 'My first NFT cat',
            image: 'https://c.tenor.com/13FWU4hPOZEAAAAd/bitcoin-satoshi.gif'
        }
    })
};

fetch('https://api.metakeep.xyz/v2/app/nft/mint', options)
    .then(response => response.json())
    .then(response => console.log(response))
    .catch(err => console.error(err));

Running the Demo

You can find the end-to-end working demo here. Follow these steps to run the demo:

Step 1: Update .env file

Update the .env file with the API key and user email address to whom you want to issue the minted token.

Step 2: Run the script

Navigate to nfts/scripts directory. Then, run the command:

npm install
npm run createCollectionAndMintToken

The demo will create an NFT collection, and wait for the transaction mining. Then, it will mint an NFT token and wait for transaction mining again. You will see the created collection address and minted token id in the output of the script.

Next Steps

Congratulations!!! You have successfully Minted the NFT token πŸŽ‰πŸŽ‰.

NOTE: If you want to deploy your own NFT smart contract with a custom Logic, you should use our Lambda Infrastructure. You can read more about MetaKeep Lambda here.

In the following tutorials, we will discuss NFT P2P transfers, locking and unlocking NFT tokens to make them non-transferable, and much more. By the end of this tutorial series, you will have built a complete end-to-end solution for NFTs.