合集容器

令牌和数据合集容器概述

本节介绍如何创建一种特殊类型的原子数字对象,称为容器(Collection)。它专为 NFT 集合等而设计。基本上任何时候我们想要将项目分组在一起时,我们都会使用容器。

快速概览:什么是容器?

容器是人类可读的标识符,用于表示 NFT 和元数据的集合。容器名称以主题标签 # 符号开头。容器名称是使用 Atomicals 数字对象格式直接在比特币区块链上自行拥有和自行管理的 - 添加和更新容器集合中的项目,并可选择永久密封容器以防止将来发生更改

合集格式(推荐)

出于效率原因,属性与项目属性关联分开定义。数值用于将每个项目的属性链接或连接到属性定义。 请参阅 github 中的示例集合格式

name(可选,string 类型)

name 字段定义集合的显示名称。集合容器本身用#标签slug(例如:#mycollection-name)进行标识,名称是网站可以用来显示更具描述性的名称。

desc (可选,string 类型)

desc 字段定义集合的详细描述。

legal 定义了规则条款和许可,以明确 NFT 的用户和持有者如何使用数据

terms (推荐): 集合使用或项目使用的任何特定条款

license (推荐): 任何类型的许可证代码

"legal": {
    "terms": "...",
    "license": "CC",
}

链接部分定义了其他的外部资源,例如网站和社交媒体链接。

{
    "links": {
        "x": {
            "v": "https://x./com/..."
        },
        "website": {
            "v": "https://..."
        },
        "art-assets.zip": {
            "v": "atom:btc:dat:<dat_id>/assets.zip"
        },
        "realm": {
            "v": "atom:btc:realm:myrealmname.subrealm"
        },
        "othercontainer": {
            "v": "atom:btc:container:relatedcollection-of-cool-things"
        },
        "discord": {
            "v": "https://discord.gg/..."
        }
    }
}

attrs (可选,object 类型)

attrs 部分定义属性的类型及其详细信息,例如名称、描述和可能的值范围。

items(必须,object 类型)

item 使用项目密钥将所有 NFT 连接到容器,建立使用项目键的字符串,即使使用编号方案也是如此

id (required): 代表项目的“id”,对应于 NFT 的 Atomical ID

a (required): 代表项目的“属性”。要求采用数组的形式,数组中的每个元素代表属性定义部分 attr 中的关联值

n (optional): 代表项目的名称

{
  "name": "Collection Name",
  "desc": "Collection description",
  "image": "atom:btc:dat:<location of store-file data>/image.png",
  "legal": {
    "terms": "...",
    "license": "CC"
  },
  "links": {
        "x": {
            "v": "https://x./com/..."
        },
        "website": {
            "v": "https://..."
        },
        "art-assets.zip": {
            "v": "atom:btc:dat:<dat_id>/assets.zip"
        },
        "realm": {
            "v": "atom:btc:realm:myrealmname.subrealm"
        },
        "othercontainer": {
            "v": "atom:btc:container:relatedcollection-of-cool-things"
        },
        "discord": {
            "v": "https://discord.gg/..."
        }
  },
  "attrs": [
    {
      "name": "bodyarmor",
      "desc": "Type of body armor",
      "type": "string",
      "values": [
        "metal",
        "leather",
        "field"
      ]
    },
    {
      "name": "headcovering",
      "desc": "The type of head covering",
      "type": "string",
      "values": [
        "bandana",
        "helmet",
        "scarf",
        "baseball cap"
      ]
    },
    {
      "name": "stamina",
      "desc": "The stamina of the hero",
      "type": "integer",
      "min": 0,
      "max": 10
    }
  ],
  "items": {
    "0": {
      "id": "84718b469c40b1bcc7cb324b8e24e4e442f88cd913687ea2bc7b3e79d4fc4fdei0",
      "n": "Some Name",
      "a": [
        0,
        3,
        8
      ]
    },
    "1": {
      "id": "1070d7c98304bf5ac9a5addceb13e0ce4e840641f82d71d84cebbdac427c1f4fi0",
      "n": "Another Name",
      "a": [
        1,
        2,
        10
      ]
    },
    "Signature Series 1": {
      "id": "14a0d7c98304bf5ac9a5addceb1de0ce4e840641f82d71d84cebbdac427c1fc3i0",
      "n": "Special",
      "a": [
        2,
        3,
        7
      ]
    }
  }
}

按照上述格式格式化集合信息后,执行以下指令

// first store the desired main image on chain (see section below)
npm run cli store-file ./path/to/image.png image.png --satsbyte=10

Success sent tx:  db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461f
{
  "success": true,
  "data": {
    "commitTxid": "b57bad8c0b7f58a552574fafc16b6efbbb3bf966b9ccfb24f03580f9462b5997",
    "revealTxid": "db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461f",
    "dataId": "db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461fi0"
  }
}

// We will use the dataId above to reference the data on chain
// ie: atom:btc:dat:db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461fi0/image.png

// Store the collection metadata with the following command:
npm run cli set-container-data #mycollection-name collection.json --satsbyte=10

推荐的最低限度集合格式

{
  "name": "Collection Name",
  "image": "atom:btc:dat:<location of store-file data>/image.png",
  "items": {
    "0": {
      "id": "84718b469c40b1bcc7cb324b8e24e4e442f88cd913687ea2bc7b3e79d4fc4fdei0"
    },
    "1": {
      "id": "1070d7c98304bf5ac9a5addceb13e0ce4e840641f82d71d84cebbdac427c1f4fi0"
    },
    "9999": {
      "id": "14a0d7c98304bf5ac9a5addceb1de0ce4e840641f82d71d84cebbdac427c1fc3i0"
    }
  }
}

按照上述格式格式化集合信息后,执行以下指令

// first store the desired main image on chain (see section below)
npm run cli store-file ./path/to/image.png image.png --satsbyte=10

Success sent tx:  db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461f
{
  "success": true,
  "data": {
    "commitTxid": "b57bad8c0b7f58a552574fafc16b6efbbb3bf966b9ccfb24f03580f9462b5997",
    "revealTxid": "db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461f",
    "dataId": "db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461fi0"
  }
}

// We will use the dataId above to reference the data on chain
// ie: atom:btc:dat:db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461fi0/image.png

// Store the collection metadata with the following command:
npm run cli set-container-data #mycollection-name collection.json --satsbyte=10

在链上存储不可变的图像文件

page永久文件存储

使用命令行程序,执行以下命令来设置上面示例文件中的数据

// immutably store an image on-chain to reference in the container metadata
npm run cli store-file ./path/to/image.png image.png --satsbyte=10

Success sent tx:  db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461f
{
  "success": true,
  "data": {
    "commitTxid": "b57bad8c0b7f58a552574fafc16b6efbbb3bf966b9ccfb24f03580f9462b5997",
    "revealTxid": "db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461f",
    "dataId": "db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461fi0"
  }
}

我们将使用揭示位置 db8a761ed493627138c5733071558c4caa65912c5cba3e1061c02d6d7933461fi0 来引用下面的图片 image.png

将 NFT 添加到合集容器中

提供与上述合集格式匹配的文件,并执行以下命令来更新示例 #mycollection-name

npm run cli set-container-data #mycollection-name sample-collection.json --satsbyte=10

查询合集容器元数据和项目

在交易被确认后,可以使用以下的命令查询 #mycollection-name 的状态

npm run cli state #mycollection-name

Last updated