# 鑄造 NFT

## 建立 NFT 但不立即鑄造

在 Qubic Creator 的設計下，你需要先透過以下 GraphQL 語法，在已存在的 Contract 中建立一個 NFT Asset 草稿，並設置其圖片與內容。在執行操作前需要先 [取得 Ticket](/docs/api/creator-admin-api/qu-de-ticket.md)。

***GraphQL Mutation Example***

```graphql
mutation {
  assetCreate(
    ticket: "TICKET"
    contractId: "123"
    input: {
      metadata: {
        name: "My First NFT"
        description: "This is my first NFT"
        externalLink: "https://myfirstnft.com"
        backgroundColor: "#CCC"
        animation: "" # or animationUrl
        image: "" # or imageUrl
        imageThumbnail: "" # or imageThumbnailUrl
        traits: [
          {
            type: "Color"
            value: "Blue"
            displayType: "STRING"
          }
        ]
      }
      saleData: {
        currency: "TWD"
        freeMintEnabled: false
        maxOrderLimit: {
          enabled: true
          limit: 10
        }
        variants: [
          {
            maxQuantity: 1
            supply: 100
            price: "1000"
          }
        ]
      }
    }
  ) {
    id
    createdAt
  }
}
```

***Result***

```json
{
  "data": {
    "assetCreate": {
      "id": "4741429652311985058",
      "createdAt": "2023-10-17T07:35:33.911979544Z"
    }
  }
}
```

NFT Asset 並不會立即被鑄造出來，僅會先暫存在 Qubic Creator 的系統中，直到被購買或空投後才會鑄造上鏈並實際被區塊鏈記載。

{% hint style="info" %}
已經建立的 NFT Asset 可以在前台商城被瀏覽與查找，但可以添加更多設置來管理發佈時間、預售與展示設定，可以避免被用戶提早購買，請參考 [如何設置預售選項](/docs/api/creator-admin-api/ru-he-she-zhi-yu-shou-xuan-xiang.md) 。
{% endhint %}

你也可以在實際鑄造（或空投）前多次修改 NFT Asset 的圖片與內容。

```graphql
mutation {
  assetUpdate(
    ticket: "TICKET"
    assetId: "4741429652311985058"
    input: {
      metadata: {
        name: "My First NFT"
        description: "This is my first NFT"
        externalLink: "https://myfirstnft.com"
        backgroundColor: "#CCC"
        animation: "" # or animationUrl
        image: "" # or imageUrl
        imageThumbnail: "" # or imageThumbnailUrl
        traits: [
          {
            type: "Color"
            value: "Red"
            displayType: "STRING"
          }
        ]
      }
      saleData: {
        currency: "TWD"
        freeMintEnabled: false
        maxOrderLimit: {
          enabled: true
          limit: 10
        }
        variants: [
          {
            maxQuantity: 1
            supply: 100
            price: "1000"
          }
        ]
      }
    }
  ) {
    id
    updatedAt
  }
}
```

***Result***

```json
{
  "data": {
    "assetUpdate": {
      "id": "4741429652311985058",
      "updatedAt": "2023-10-17T07:35:33.911979544Z"
    }
  }
}
```

## 直接鑄造（空投）

執行空投前需要先 [建立 NFT](#jian-li-nft-dan-bu-li-ji-zhu-zao)，

```graphql
mutation {
  assetMint(
    assetId: "4741429652311985058"
    input: { 
      requestId: "xxxxx"
      variantId: "yyyyy"
      recipients: [
        {
          address: "0x"
          tokenId: "123456"
          quantity: 1
        }
      ]
      ensureBuyState: true 
    }
  )
}

```

***Result***

```json
{
  "data": {
    "assetMint": "4741429652311985058"
  }
}
```

##

## 引導購買者至付款頁面

一但 NFT Asset 被建立，就會在前端商城中產生一個唯一網址，其網址生成邏輯如下。

```
https://{your-domain}/store/products/{assetId}
```

{% hint style="info" %}
你必須已經開啟商城網站，此網址才會有效
{% endhint %}

你可以放心將用戶引導到該網址完成付款購買或是免費領取，無論你對 NFT Asset 的內容做過多少次變更，此網址都會是連結到指定商品頁面的唯一路徑。

如果你沒有開啟公版商城的付款頁面，或是不想要用公版商城的付款頁面讓用戶完成付款，你依然可以結合 Qubic Storefront GraphQL API 和 Qubic Connect SDK 提供的結帳功能來創造 [自定義的結帳流程](/docs/guides/qubic-connect-sdk/checkout-and-payment.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://qubic.gitbook.io/docs/api/creator-admin-api/mint-nft.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
