standard-udt sUDT Type Script 约束standard-udt sUDT Type Script Constraints
来源:xcshuan/ckb-standard-udt-contracts @d6e6da0 contracts/sudt/src、lib/script-utils、lib/types · 仓库未公布部署(SUDT_CODE_HASH 为构建期常量)Source: xcshuan/ckb-standard-udt-contracts @d6e6da0 contracts/sudt/src, lib/script-utils, lib/types · no deployment published (SUDT_CODE_HASH is a build-time constant)
给 AI agent:For AI agents: std_sudt.md · llms.txt
Σin ≥ Σout转账 / 销毁(sudt 只检查格式)Transfer / burn (sudt only checks format)
Inputs 输入Inputs
sUDTCell{
type: SUDT{ args: meta_type_hash } (data2),
data: amount
}
Outputs 输出Outputs
sUDTCell{
type: SUDT{ args: meta_type_hash } (data2),
data: amount′
}
sUDT cellsUDT cell
type.args32B
data[0..16]16B u128 LE
- type.args32B元数据 cell 的 type hash(type id 脚本的 hash)type hash of the metadata cell长度 = 32length = 3220
- data[0..16]16B u128 LE数量;之后的字节被忽略amount; trailing bytes ignored≥ 16B≥ 16B30
sudt-meta 只统计 hash_type = data2、code_hash = SUDT_CODE_HASH、args = 元数据 type hash 的 cellsudt-meta only counts cells with hash_type = data2, code_hash = SUDT_CODE_HASH, args = metadata type hash
限制Constraints
- args= 32B= 32B20
- data组内每个 cell ≥ 16Bevery group cell ≥ 16B30
- Σu128 求和不溢出u128 sums do not overflow31
- 分类classificationΣ输出 ≤ Σ输入 时 sudt 直接通过;若交易消费元数据 cell,减少量由 sudt-meta 记为协议销毁,否则为用户销毁(不减 supply)Σout ≤ Σin passes in sudt; if the tx spends the metadata cell, sudt-meta accounts the decrease as a protocol burn, else it is user destruction (supply unchanged)—
Σin < Σout铸造Mint
Inputs 输入Inputs
sUDTCell{
type: SUDT{ args: meta_type_hash } (data2),
data: amount
}
元数据 cell(tracked 必须作为输入)metadata cell (must be an input when tracked)Cell{ type: hash = args, data: SudtMeta }
Outputs 输出Outputs
sUDTCell{
type: SUDT{ args: meta_type_hash } (data2),
data: amount + minted
}
sUDT cellsUDT cell
type.args32B
data[0..16]16B u128 LE
- type.args32B元数据 cell 的 type hash(type id 脚本的 hash)type hash of the metadata cell长度 = 32length = 3220
- data[0..16]16B u128 LE数量;之后的字节被忽略amount; trailing bytes ignored≥ 16B≥ 16B30
sudt-meta 只统计 hash_type = data2、code_hash = SUDT_CODE_HASH、args = 元数据 type hash 的 cellsudt-meta only counts cells with hash_type = data2, code_hash = SUDT_CODE_HASH, args = metadata type hash
cell_deps:untracked 时元数据 cell 可在 cell_depscell_deps: when untracked the metadata cell may be a cell_dep
限制Constraints
- args= 32B= 32B20
- data≥ 16B≥ 16B30
- 定位元数据locate metadata先 cell_deps、再输入,type hash = args;同一来源多于一个 → 42;解析失败 → 40cell_deps first, then inputs, type hash = args; more than one in a source → 42; parse failure → 4042 / 40
- 首次铸造initial mintcell_deps / 输入都没有时,输出中必须有元数据 cell(由 sudt-meta 校验创建)if neither has it, the outputs must contain the metadata cell (creation checked by sudt-meta)41
- tracked元数据必须来自输入(来自 cell_dep → 43);supply 由 sudt-meta 记账metadata must come from an input (cell_dep → 43); supply is accounted by sudt-meta43
- untrackedmint_authority 存在且通过mint_authority exists and passes50 / 51 / 52
- untrackedcurrent_supply = 0current_supply = 045
部署与来源Deployments & source 未核验unverified
源码source
xcshuan/ckb-standard-udt-contracts@d6e6da01 · contracts/sudt/src · lib/script-utils/src/amount.rs · lib/script-utils/src/authority.rs · lib/types/src/metadata · lib/types/src/schemas/metadata.mol (commit read when writing this spec (default-branch HEAD, 2026-05-18). No deployment or code_hash is published (dependent code hashes are injected at build time); checksums.txt lists sha256 of release binaries only.)
二进制核验binary check
未核验unverified no deployment resolved on chain
未在链上找到部署no on-chain deployment resolved
链上数据核对于 on-chain data checked 2026-11-12
错误码(contracts/sudt/src/error.rs):1–9 SysError、10 SyscallUnknown、20 InvalidArgs、30 AmountEncoding、31 AmountOverflow、32 SupplyOverflow、33 SupplyUnderflow、40 InvalidMetaData、41 MetaMissing、42 MetaNotUnique、43 MetaInputMissing、44 MetaOutputMissing、45 MetaStateMismatch、50 AuthorityMissing、51 AuthorityFailed、52 UnsupportedAuthorityLocation。32、33、44 在 sudt 中未使用。Error codes (contracts/sudt/src/error.rs): 1–9 SysError, 10 SyscallUnknown, 20 InvalidArgs, 30 AmountEncoding, 31 AmountOverflow, 32 SupplyOverflow, 33 SupplyUnderflow, 40 InvalidMetaData, 41 MetaMissing, 42 MetaNotUnique, 43 MetaInputMissing, 44 MetaOutputMissing, 45 MetaStateMismatch, 50 AuthorityMissing, 51 AuthorityFailed, 52 UnsupportedAuthorityLocation. 32, 33 and 44 are unused in sudt.
README 说 sudt 校验“协议销毁分类与用户销毁”,但 entry.rs 只在 Σ输出 > Σ输入 时调用 validate_mint;减少量完全由 sudt-meta(当元数据 cell 被消费时)记账。The README says sudt validates “protocol-burn classification and user destruction”, but entry.rs only calls validate_mint when Σout > Σin; decreases are accounted solely by sudt-meta (when the metadata cell is spent).
sudt 不检查自身 hash_type,而 sudt-meta 只统计 data2 绑定的 cell:用其他 hash_type 引用同一二进制的 sUDT 不会计入 tracked supply。untracked 首次铸造(元数据在输出中)不检查 authority。sudt does not check its own hash_type, while sudt-meta only counts data2-bound cells: an sUDT referencing the same binary with another hash_type is not counted in tracked supply. An untracked initial mint (metadata in outputs) checks no authority.
授权方式:InputLock / InputType = 输入中有该 lock / type hash;OutputType = 输出中有该 type hash;DynamicLinking 调用 udt_authorize;Spawn 退出码 0Authority: InputLock / InputType = an input has that lock / type hash; OutputType = an output has that type hash; DynamicLinking calls udt_authorize; Spawn must exit 0
部署:仓库未公布 code_hash;本页 match 为空、无测试交易。Deployment: no code_hash is published; match is empty and there is no test tx.
README 说 sudt 校验“协议销毁分类与用户销毁”,但 entry.rs 只在 Σ输出 > Σ输入 时调用 validate_mint;减少量完全由 sudt-meta(当元数据 cell 被消费时)记账。The README says sudt validates “protocol-burn classification and user destruction”, but entry.rs only calls validate_mint when Σout > Σin; decreases are accounted solely by sudt-meta (when the metadata cell is spent).
sudt 不检查自身 hash_type,而 sudt-meta 只统计 data2 绑定的 cell:用其他 hash_type 引用同一二进制的 sUDT 不会计入 tracked supply。untracked 首次铸造(元数据在输出中)不检查 authority。sudt does not check its own hash_type, while sudt-meta only counts data2-bound cells: an sUDT referencing the same binary with another hash_type is not counted in tracked supply. An untracked initial mint (metadata in outputs) checks no authority.
授权方式:InputLock / InputType = 输入中有该 lock / type hash;OutputType = 输出中有该 type hash;DynamicLinking 调用 udt_authorize;Spawn 退出码 0Authority: InputLock / InputType = an input has that lock / type hash; OutputType = an output has that type hash; DynamicLinking calls udt_authorize; Spawn must exit 0
部署:仓库未公布 code_hash;本页 match 为空、无测试交易。Deployment: no code_hash is published; match is empty and there is no test tx.