M-NFT Class 约束M-NFT Class Constraints
来源:nervina-labs/ckb-nft-scripts @b5af002 contracts/class-type/src/entry.rs · mainnet 0xd51e…3d9a / testnet 0x095b…e3fc (type)Source: nervina-labs/ckb-nft-scripts @b5af002 contracts/class-type/src/entry.rs · mainnet 0xd51e…3d9a / testnet 0x095b…e3fc (type)
给 AI agent:For AI agents: mnft_class.md · llms.txt
0 → n创建 class(issuer 1 → 1)Create classes (issuer 1 → 1)
Inputs 输入Inputs
Issuer cellCell{ type: ISSUER (hash[0..20] = issuer_id), data: { class_count: a } }
Outputs 输出Outputs
Issuer cellCell{ type: ISSUER, data: { class_count: b > a } }
Class cell × (b − a)Cell{
type: { codeHash: CLASS_TYPE, hashType: type,
args: issuer_id 20B ‖ class_id u32 BE },
data: version 0 ‖ total ‖ issued 0 ‖ configure ‖ name ‖ description ‖ renderer ‖ [extinfo]
}
argsargs
issuer_id20B
class_id4B BE
- issuer_id20Bissuer type hash[0..20]issuer type hash[0..20]输入恰有 1 个这样的 issuerexactly 1 such issuer input6
- class_id4B BE序号index= a, a+1, …(按输出顺序)= a, a+1, … (output order)18
data 字节布局(大端)data byte layout (big-endian)
version1B
total4B
issued4B
configure1B
name / descriptionu16 ‖ bytes
rendereru16 ‖ bytes
- version1B版本version= 011
- total4B上限(0 = 无限)cap (0 = unlimited)不可变;>0 时 issued ≤ totalimmutable; issued ≤ total when > 013 / 16
- issued4B已铸造minted创建 = 0;不减0 on create; never decreases15
- configure1BNFT 权限位NFT permission bits不可变immutable16
- name / descriptionu16 ‖ bytes名称 / 描述name / description不可变immutable12 / 16
- rendereru16 ‖ bytes渲染地址renderer可改mutable12
限制Constraints
- args恰 24 字节exactly 24 bytes7
- issuer输入中 type hash[0..20] = issuer_id 的 cell 恰 1 个;其 class_count 增加exactly 1 input whose type hash[0..20] = issuer_id; its class_count increases6 / 8
- class ids同 issuer 的 class 输出数 = 增量,id 依次为 [a..b)class outputs of this issuer = the increase, ids [a..b) in order14 / 18
- data≥ 16 字节、version 0、issued = 0≥ 16 bytes, version 0, issued = 012 / 11 / 15
n → n更新 class(如铸造 NFT 时)Update class (e.g. when minting NFTs)
Inputs 输入Inputs
Class cellCell{ type: CLASS, data: { issued: i, … } }
Outputs 输出Outputs
Class cellCell{ type: CLASS, data: { issued: ≥ i, total/configure/name/description same } }
限制Constraints
- count同 issuer 的 class cell 输入数 = 输出数class cells of this issuer: inputs = outputs14
- witness对应 WitnessArgs.lock 存在the matching WitnessArgs.lock is present40
- dataissued 不减;total、configure、name、description 不变issued never decreases; total, configure, name, description unchanged15 / 16
n → 0销毁 classDestroy class
Inputs 输入Inputs
Class cellCell{ type: CLASS, data: { issued: 0 } }
Outputs 输出Outputs
无同 issuer 的 classno class of this issuer—
限制Constraints
- witness对应 WitnessArgs.lock 存在the matching WitnessArgs.lock is present40
- issued= 017
部署与来源Deployments & source 未核验unverified
源码source
nervina-labs/ckb-nft-scripts@b5af002e · contracts/class-type/src/entry.rs · contracts/script-utils/src/class.rs · contracts/script-utils/src/issuer.rs · contracts/script-utils/src/helper.rs · contracts/script-utils/src/error.rs (deployment commit named on the wiki page Lina-Mainnet-deployment; the Aggron testnet deployment commit d0a844def34df6b05b7b8e260a6225a477f1bf39 differs only in helper.rs CLASS_TYPE_CODE_HASH)
二进制核验binary check
未核验unverified no binary or checksum at the recorded commit matched the deployed data hash (reproducible build not attempted)
| 网络network | code_hash | cell_dep | type_id args | 数据哈希data hash | 部署交易deploy tx |
|---|---|---|---|---|---|
| mainnet | 0xd51e6eaf48124c601f41abe173f1da550b4cbca9c6a166781906a287abbb3d9a type | 0x5dce8acab1…dc21d471:1 code | 0x9b645aade5…727430f9 | 0xc9aa394982…9cd95125 | 0x5dce8acab1…dc21d471 #5913754 |
| testnet | 0x095b8c0b4e51a45f953acd1fcd1e39489f2675b4bc94e7af27bb38958790e3fc type | 0xf11ccb6079…64a4bd1c:1 code | 0x72236511c0…8da464fd | 0x682a109037…be12a9d3 | 0xf11ccb6079…64a4bd1c #3463076 |
链上数据核对于 on-chain data checked 2026-11-06
版本:wiki Lina-Mainnet-deployment 写明部署提交 b5af002,Aggron-Testnet-deployment 写明 d0a844d;两者合约代码只差 helper.rs 中 CLASS_TYPE_CODE_HASH 常量(主网 0xd51e…3d9a / 测试网 0x095b…e3fc)。之后的提交只调整目录结构与 capsule 版本。未做可复现构建。Version: the wiki Lina-Mainnet-deployment page names deployment commit b5af002 and Aggron-Testnet-deployment names d0a844d; the contract code differs only in helper.rs CLASS_TYPE_CODE_HASH (mainnet 0xd51e…3d9a / testnet 0x095b…e3fc). Later commits only restructure directories and bump capsule. No reproducible build was attempted.
动作判断按“同一 issuer 的所有 class”计数(code_hash、hash_type 相同,args 24 字节且前 20 字节相同),不是只看本 class;但只校验本 group 第一个输入 / 输出的 data。The action is decided by counting all classes of the same issuer (same code_hash and hash_type, 24-byte args with the same first 20 bytes), not just this class; only this group's first input / output data is validated.
规则 40(helper.rs):找到第一个带此 type 的输入,取它的 lock,再找第一个使用该 lock 的输入;该位置的 WitnessArgs.lock 必须存在(witness 缺失或解析失败也算缺失),用于禁止 ACP 这类不签名的 lock 更新 / 销毁。Rule 40 (helper.rs): take the first input with this type, take its lock, find the first input with that lock; the WitnessArgs.lock at that index must be present (a missing or unparsable witness counts as absent). It blocks signature-less locks such as ACP from updating / destroying.
错误码(script-utils/src/error.rs,wiki Error-Codes):1–4 syscall · 5 IssuerDataInvalid · 6 IssuerCellsCountError · 7 TypeArgsInvalid · 8 IssuerClassCountError · 9 IssuerSetCountError · 10 IssuerCellCannotDestroyed · 11 VersionInvalid · 12 ClassDataInvalid · 13 ClassTotalSmallerThanIssued · 14 ClassCellsCountError · 15 ClassIssuedInvalid · 16 ClassImmutableFieldsNotSame · 17 ClassCellCannotDestroyed · 18 ClassIdIncreaseError · 19 NFTDataInvalid · 20 NFTCellsCountError · 21 NFTTokenIdIncreaseError · 22–39 NFT 状态规则 · 40 GroupInputWitnessNoneErrorError codes (script-utils/src/error.rs, wiki Error-Codes): 1–4 syscall · 5 IssuerDataInvalid · 6 IssuerCellsCountError · 7 TypeArgsInvalid · 8 IssuerClassCountError · 9 IssuerSetCountError · 10 IssuerCellCannotDestroyed · 11 VersionInvalid · 12 ClassDataInvalid · 13 ClassTotalSmallerThanIssued · 14 ClassCellsCountError · 15 ClassIssuedInvalid · 16 ClassImmutableFieldsNotSame · 17 ClassCellCannotDestroyed · 18 ClassIdIncreaseError · 19 NFTDataInvalid · 20 NFTCellsCountError · 21 NFTTokenIdIncreaseError · 22–39 NFT state rules · 40 GroupInputWitnessNoneError
2026-11-19 上游审阅(非链上升级声明):官方 wiki 仍固定 Lina=b5af002、Aggron=d0a844d;与 HEAD 的差异为格式/导入整理及 helper 内 CLASS_TYPE_CODE_HASH 从 Lina 改为 Aggron。不能用 Aggron 常量替换主网;维持按网络选择 class hash,数据布局、转换和错误码不变。2026-11-19 upstream review (not an on-chain upgrade claim): Official wiki still pins Lina=b5af002 and Aggron=d0a844d. HEAD differs by formatting/import cleanup and switching helper CLASS_TYPE_CODE_HASH from Lina to Aggron. Do not replace the mainnet constant with Aggron; retain network-specific class hashes, layouts, transitions and errors.
动作判断按“同一 issuer 的所有 class”计数(code_hash、hash_type 相同,args 24 字节且前 20 字节相同),不是只看本 class;但只校验本 group 第一个输入 / 输出的 data。The action is decided by counting all classes of the same issuer (same code_hash and hash_type, 24-byte args with the same first 20 bytes), not just this class; only this group's first input / output data is validated.
规则 40(helper.rs):找到第一个带此 type 的输入,取它的 lock,再找第一个使用该 lock 的输入;该位置的 WitnessArgs.lock 必须存在(witness 缺失或解析失败也算缺失),用于禁止 ACP 这类不签名的 lock 更新 / 销毁。Rule 40 (helper.rs): take the first input with this type, take its lock, find the first input with that lock; the WitnessArgs.lock at that index must be present (a missing or unparsable witness counts as absent). It blocks signature-less locks such as ACP from updating / destroying.
错误码(script-utils/src/error.rs,wiki Error-Codes):1–4 syscall · 5 IssuerDataInvalid · 6 IssuerCellsCountError · 7 TypeArgsInvalid · 8 IssuerClassCountError · 9 IssuerSetCountError · 10 IssuerCellCannotDestroyed · 11 VersionInvalid · 12 ClassDataInvalid · 13 ClassTotalSmallerThanIssued · 14 ClassCellsCountError · 15 ClassIssuedInvalid · 16 ClassImmutableFieldsNotSame · 17 ClassCellCannotDestroyed · 18 ClassIdIncreaseError · 19 NFTDataInvalid · 20 NFTCellsCountError · 21 NFTTokenIdIncreaseError · 22–39 NFT 状态规则 · 40 GroupInputWitnessNoneErrorError codes (script-utils/src/error.rs, wiki Error-Codes): 1–4 syscall · 5 IssuerDataInvalid · 6 IssuerCellsCountError · 7 TypeArgsInvalid · 8 IssuerClassCountError · 9 IssuerSetCountError · 10 IssuerCellCannotDestroyed · 11 VersionInvalid · 12 ClassDataInvalid · 13 ClassTotalSmallerThanIssued · 14 ClassCellsCountError · 15 ClassIssuedInvalid · 16 ClassImmutableFieldsNotSame · 17 ClassCellCannotDestroyed · 18 ClassIdIncreaseError · 19 NFTDataInvalid · 20 NFTCellsCountError · 21 NFTTokenIdIncreaseError · 22–39 NFT state rules · 40 GroupInputWitnessNoneError
2026-11-19 上游审阅(非链上升级声明):官方 wiki 仍固定 Lina=b5af002、Aggron=d0a844d;与 HEAD 的差异为格式/导入整理及 helper 内 CLASS_TYPE_CODE_HASH 从 Lina 改为 Aggron。不能用 Aggron 常量替换主网;维持按网络选择 class hash,数据布局、转换和错误码不变。2026-11-19 upstream review (not an on-chain upgrade claim): Official wiki still pins Lina=b5af002 and Aggron=d0a844d. HEAD differs by formatting/import cleanup and switching helper CLASS_TYPE_CODE_HASH from Lina to Aggron. Do not replace the mainnet constant with Aggron; retain network-specific class hashes, layouts, transitions and errors.