How to batch mint NFTs to multiple destinations?

This guide will explain how you can mint and send NFTs to multiple wallets in a batch.

Scenario Explained

In this guide we will be working with the NFT-API.

We will build an API request that allows you to mint and send NFTs to multiple wallet addresses with a single call.

End Result

Instead of minting individual NFTs, you will batch mint NFTs to multiple wallet addresses.

Prerequisites

  1. You need a Venly business account, if you don't have one, click here to register in our Business Portal, or follow our step-by-step guide, Getting Started with Venly.
  2. You need an active trial or paid subscription of the NFT-API. You can start a 30-day free trial for the NFT-API as shown below.
  3. You need your Client ID and Client Secret which can be obtained from the Portal as shown below.
  4. You need a contract with a contractId and token-type with typeId . Learn how to create a contract and token-type.
Starting a trial subscription and obtaining a Client ID and Client Secret

Batch Minting NFTs

We will use the following endpoint along with the contractId and typeId in the path. We have specified three different wallet addresses in the request body.

Similarly you can add as many wallet addresses as you want by following the syntax in the request body. While specifying the wallet address, you can also specify the number of NFTs you wish to mint per wallet address.

In this example, we have specified one NFT for the first address, two NFTs for the second address, and one NFT for the third address.

Request Endpoint: reference

 POST /api/minter/contracts/{contractId}/types/{typeId}/tokens
ParameterParam TypeDescriptionTypeRequired
{contractId}PathThis is the ID of the contract. You can get it from the response body when you create a contract.String
{typeId}PathThis is the ID of the token-type. You can get it from the response body when you create a token-type.String
destinationsBodyThe array which includes all the wallet addresses and number of NFTs to mint per wallet addressArray
addressBodyThe wallet address to mint and send the NFTString
amountBodyThe number of NFTs you want to mint and sendInteger

Request Body:

{
  "destinations": [
    {
      "address": "0x9282fc38931A3a613b8566b3E6a1027e49ABb712",
      "amount": 1
    },
    {
      "address": "0xe396E30554F97088FA6f9297339c3bDc575ba306",
      "amount": 2
    },
    {
      "address": "0x329CdCBBD82c934fe32322b423bD8fBd30b4EEB6",
      "amount": 1
    }
  ]
}

Response Body:

📘

Under the mintedTokens array, you can find individual transaction hash for each minted NFT listed with the wallet address and respective tokenId.

tokenId: This is a unique identifier which distinguishes one NFT from another which are minted under the same contract and token-type.

[
  {
    "transactionHash": "0xeffe03d4eafc7e52e93580ff5c2dec6a64ab31be9abc5e6556976804c0d1fa66",
    "metadata": {
      "name": "My first NFT",
      "description": "Venly",
      "image": "https://storage-qa.venly.io/applications/1f64ded9-2a05-4824-b682-661023359357/StickFigureHi.png",
      "imagePreview": "https://storage-qa.venly.io/applications/1f64ded9-2a05-4824-b682-661023359357/StickFigureHi.png",
      "imageThumbnail": "https://storage-qa.venly.io/applications/1f64ded9-2a05-4824-b682-661023359357/StickFigureHi.png",
      "animationUrls": [],
      "attributes": [
        {
          "type": "system",
          "name": "tokenTypeId",
          "value": "1",
          "traitType": "Token Type ID",
          "trait_type": "Token Type ID"
        }
      ],
      "contract": {
        "address": "0x4d7d22186963fc3d884aa8d1bf54c7233beddbf3",
        "name": "My first collection",
        "symbol": "MYFICO",
        "image": "https://pbs.twimg.com/profile_images/1669300450649157635/4xg-wsbK_400x400.jpg",
        "imageUrl": "https://pbs.twimg.com/profile_images/1669300450649157635/4xg-wsbK_400x400.jpg",
        "image_url": "https://pbs.twimg.com/profile_images/1669300450649157635/4xg-wsbK_400x400.jpg",
        "description": "Sample description",
        "externalLink": "www.venly.io",
        "external_link": "www.venly.io",
        "externalUrl": "www.venly.io",
        "external_url": "www.venly.io",
        "media": [],
        "type": "ERC_1155"
      },
      "fungible": false
    },
    "destinations": [
      "0x9282fc38931A3a613b8566b3E6a1027e49ABb712",
      "0xe396E30554F97088FA6f9297339c3bDc575ba306",
      "0xe396E30554F97088FA6f9297339c3bDc575ba306",
      "0x329CdCBBD82c934fe32322b423bD8fBd30b4EEB6"
    ],
    "tokenIds": [
      5,
      6,
      7,
      8
    ],
    "mintedTokens": [
      {
        "destination": "0x9282fc38931A3a613b8566b3E6a1027e49ABb712",
        "tokenId": 5,
        "txHash": "0xeffe03d4eafc7e52e93580ff5c2dec6a64ab31be9abc5e6556976804c0d1fa66"
      },
      {
        "destination": "0xe396E30554F97088FA6f9297339c3bDc575ba306",
        "tokenId": 6,
        "txHash": "0xeffe03d4eafc7e52e93580ff5c2dec6a64ab31be9abc5e6556976804c0d1fa66"
      },
      {
        "destination": "0xe396E30554F97088FA6f9297339c3bDc575ba306",
        "tokenId": 7,
        "txHash": "0xeffe03d4eafc7e52e93580ff5c2dec6a64ab31be9abc5e6556976804c0d1fa66"
      },
      {
        "destination": "0x329CdCBBD82c934fe32322b423bD8fBd30b4EEB6",
        "tokenId": 8,
        "txHash": "0xeffe03d4eafc7e52e93580ff5c2dec6a64ab31be9abc5e6556976804c0d1fa66"
      }
    ]
  }
]