# NFT minting

## **createnft** <a href="#createnft" id="createnft"></a>

Mint a new NFT.

## Basic Information <a href="#basic-info" id="basic-info"></a>

<table><thead><tr><th width="134">Property</th><th width="226">Detail</th></tr></thead><tbody><tr><td>URL</td><td><code>/api/v1/createnft</code></td></tr><tr><td>Method</td><td>POST</td></tr></tbody></table>

## **R**equest parameter <a href="#request" id="request"></a>

<table><thead><tr><th width="231">Parameter</th><th width="85">Type</th><th width="102">Required</th><th width="329">Detail</th></tr></thead><tbody><tr><td>contract_address</td><td>str</td><td>yes</td><td>Address of collection (contract)</td></tr><tr><td>blockchain</td><td>str</td><td>yes</td><td>Blockchain for minting NFTs</td></tr><tr><td>receiver_wallet_address</td><td>str</td><td>yes</td><td>Owner of the NFT to be mint</td></tr><tr><td>metadata</td><td>object</td><td>yes</td><td>NFT metadata (see below)</td></tr></tbody></table>

## Blockchains that can be specified in the `blockchain` parameter <a href="#parameter" id="parameter"></a>

Please specify the name of the network item on the [Supported blockchain](https://docs.nftgarden.app/en/supported-blockchains) page.

{% hint style="info" %}
The blockchain specified in the `blockchain` parameter must match the blockchain in the collection (`contract_address`).
{% endhint %}

## **metadata** <a href="#metadata" id="metadata"></a>

Define NFT metadata. Items that require file upload are specified in `file_fields`.

<table><thead><tr><th width="149">Parameter</th><th width="76">Type</th><th width="104">Required</th><th width="419">Detail</th></tr></thead><tbody><tr><td>title</td><td>str</td><td>Yes</td><td>NFT title</td></tr><tr><td>description</td><td>str</td><td>Yes</td><td>NFT description</td></tr><tr><td>file_fields</td><td>list</td><td>Yes</td><td>Metadata items that require file upload, registered as key/url pairs (see below). Maximum of 8 items.</td></tr><tr><td>attribute</td><td>list</td><td>No</td><td>Properties to add to NFT</td></tr><tr><td>Optional item</td><td>str</td><td>No</td><td>Other metadata</td></tr></tbody></table>

{% hint style="warning" %}
The number of items that can be set in the metadata is 10 in total, including `title`, `description`, each `file_fields`, and optional items.
{% endhint %}

## **file\_fields** <a href="#file-fields" id="file-fields"></a>

`file_fields` is an array of `key`, `url` pairs.

<table><thead><tr><th width="139">Parameter</th><th width="76">Type</th><th width="102">Required</th><th width="280">Detail</th></tr></thead><tbody><tr><td>key</td><td>str</td><td>Yes</td><td>Metadata key</td></tr><tr><td>url</td><td>str</td><td>Yes</td><td>URL of the file to upload</td></tr></tbody></table>

## attribute <a href="#attribute" id="attribute"></a>

`attribute` is an array of `tag`,`value` pairs.

<table><thead><tr><th width="139">Parameter</th><th width="76">Type</th><th width="106">Required</th><th width="280">Detail</th></tr></thead><tbody><tr><td>tag</td><td>str</td><td>Yes</td><td>Property Tags</td></tr><tr><td>value</td><td>str</td><td>Yes</td><td>Property Value</td></tr></tbody></table>

{% hint style="info" %}
The file specified in the URL is uploaded to IPFS or other storage.
{% endhint %}

## Sample requests <a href="#sample" id="sample"></a>

```json
{
  "contract_address": "0x0000000000000000000000000000000000000000",
  "blockchain": "polygon",
  "receiver_wallet_address": "0x1111111111111111111111111111111111111111",
  "metadata": [
    {
      "title": "NFT Name1",
      "description": "Description of NFT1",
      "file_fields": [
        {
          "key": "image",
          "url": "https://my.nftgarden.app/image.png"
        }
      ],
      "attribute": [
        {
          "tag": "color",
          "value": "Red"
        }
      ]
    },
    {
      "title": "NFT Name2",
      "description": "Description of NFT2",
      "file_fields": [
        {
          "key": "image",
          "url": "https://my.nftgarden.app/image.png"
        }
      ],
      "attribute": [
        {
          "tag": "color",
          "value": "Blue"
        }
      ]
    }
  ]
}
```

## Example of successful response <a href="#response" id="response"></a>

```json
{
  "message": "Create NFT request accepted",
  "requests": {
    "contract_address": "0x0000000000000000000000000000000000000000",
    "receiver_wallet_address": "0x1111111111111111111111111111111111111111",
    "metadata": [
      {
        "title": "NFT Name1",
        "description": "Description of NFT1",
        "file_fields": [
          {
            "key": "image",
            "url": "https://my.nftgarden.app/image.png"
          }
        ],
      "attribute": [
          {
            "tag": "color",
            "value": "Red"
          }
        ]
      },
      {
        "title": "NFT Name2",
        "description": "Description of NFT2",
        "file_fields": [
          {
            "key": "image",
            "url": "https://my.nftgarden.app/image.png"
          }
        ],
        "attribute": [
          {
            "tag": "color",
            "value": "Blue"
          }
        ]
      }
    ]
  },
  "nfts": [
    {
      "nft_gdn_ids": "cf7faf94-a5ec-462c-ad06-1bd772fefe21",
      "accepted_date": "2022-07-04 04:20:18"
    },
    {
      "nft_gdn_ids": "b27752b7-9803-4d28-b29f-9532ad0f0dbb",
      "accepted_date": "2022-07-04 04:20:18"
    }
  ]
}
```

## Example of response in case of failure(status code 400) <a href="#error" id="error"></a>

```json
{
  "error": {
    "title": "Bad Request",
    "message": "contract_address and blockchain are inconsistent"
  }
}
```
