鑄造 NFT
建立 NFT 但不立即鑄造
在 Qubic Creator 的設計下,你需要先透過以下 GraphQL 語法,在已存在的 Contract 中建立一個 NFT Asset 草稿,並設置其圖片與內容。在執行操作前需要先 取得 Ticket。
GraphQL Mutation Example
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
{
"data": {
"assetCreate": {
"id": "4741429652311985058",
"createdAt": "2023-10-17T07:35:33.911979544Z"
}
}
}
NFT Asset 並不會立即被鑄造出來,僅會先暫存在 Qubic Creator 的系統中,直到被購買或空投後才會鑄造上鏈並實際被區塊鏈記載。
你也可以在實際鑄造(或空投)前多次修改 NFT Asset 的圖片與內容。
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
{
"data": {
"assetUpdate": {
"id": "4741429652311985058",
"updatedAt": "2023-10-17T07:35:33.911979544Z"
}
}
}
直接鑄造(空投)
執行空投前需要先 建立 NFT,
mutation {
assetMint(
assetId: "4741429652311985058"
input: {
requestId: "xxxxx"
variantId: "yyyyy"
recipients: [
{
address: "0x"
tokenId: "123456"
quantity: 1
}
]
ensureBuyState: true
}
)
}
Result
{
"data": {
"assetMint": "4741429652311985058"
}
}
引導購買者至付款頁面
一但 NFT Asset 被建立,就會在前端商城中產生一個唯一網址,其網址生成邏輯如下。
https://{your-domain}/store/products/{assetId}
你可以放心將用戶引導到該網址完成付款購買或是免費領取,無論你對 NFT Asset 的內容做過多少次變更,此網址都會是連結到指定商品頁面的唯一路徑。
如果你沒有開啟公版商城的付款頁面,或是不想要用公版商城的付款頁面讓用戶完成付款,你依然可以結合 Qubic Storefront GraphQL API 和 Qubic Connect SDK 提供的結帳功能來創造 自定義的結帳流程
Last updated