sUDT(Simple UDT)合约约束sUDT (Simple UDT) Contract Constraints
来源:RFC 0025 Simple UDT · 实现 ckb-production-scripts/c/simple_udt.c@e570c11 · Lina code_hash 0x5e7a…cfd5,hash_type typeSource: RFC 0025 Simple UDT · implementation ckb-production-scripts/c/simple_udt.c@e570c11 · Lina code_hash 0x5e7a…cfd5, hash_type type
0 → N发行 / 增发(owner 模式)Issue / Mint (owner mode)
Inputs 输入Inputs
某个 input:owner cellsome input: owner cellCell{
lock: hash(lock) == sUDT.args,
type: 任意
}Cell{
lock: hash(lock) == sUDT.args,
type: any
}
➜
Outputs 输出Outputs
output:sUDT celloutput: sUDT cellCell{
lock: 任意,
type: { codeHash: sUDT, args: owner lock hash (32B) },
data: amount: u128 LE (前 16 字节)
}Cell{
lock: any,
type: { codeHash: sUDT, args: owner lock hash (32B) },
data: amount: u128 LE (first 16 bytes)
}
限制Constraints
- type.args:: 长度恰为 32 字节(owner lock script hash)exactly 32 bytes (owner lock script hash) (-1)
- owner 模式owner mode:: 任一 input 的 lock hash == args 时脚本直接通过,不检查数量if any input's lock hash == args, the script succeeds immediately without checking amounts
N → M转账 / 销毁Transfer / Burn
Inputs 输入Inputs
inputs:sUDT cell(同一 type)inputs: sUDT cells (same type)Cell{
lock: 用户 lock,
type: { codeHash: sUDT, args: owner hash },
data: amount_in (u128 LE)
}Cell{
lock: user lock,
type: { codeHash: sUDT, args: owner hash },
data: amount_in (u128 LE)
}
➜
Outputs 输出Outputs
outputs:sUDT cell(同一 type)outputs: sUDT cells (same type)Cell{
lock: 任意,
type: { codeHash: sUDT, args: owner hash },
data: amount_out (u128 LE)
}Cell{
lock: any,
type: { codeHash: sUDT, args: owner hash },
data: amount_out (u128 LE)
}
限制Constraints
- data:: 长度 ≥ 16 字节,前 16 字节为 u128 LE 数量length ≥ 16 bytes; first 16 bytes are the u128 LE amount (-2)
- Σ amount:: 累加不得溢出 u128summation must not overflow u128 (-51)
- Σ amount_in ≥ Σ amount_out(多出部分即销毁)≥ Σ amount_out (the difference is burned) (-52)
- lock:: sUDT 不限制,用户自定not restricted by sUDT; user-defined
部署与来源Deployments & source 未核验unverified
源码source nervosnetwork/ckb-production-scripts@e570c11a · c/simple_udt.c (pinned in the plugin header)
二进制核验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 | 0x5e7a36a77e68eecc013dfa2fe6a23f3b6c344b04005808694ae6dd45eea4cfd5 type | 0xc7813f6a41…4a9936d5:0 code | 0xcf37df53ec…bcf39a8b | 0xe1e354d6d6…d77df419 | 0xc7813f6a41…4a9936d5 #2624950 |
| testnet | 0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4 type | 0xe12877ebd2…25aab769:0 code | 0x4db75e0334…ee064511 | 0xe1e354d6d6…d77df419 | 0xe12877ebd2…25aab769 #586297 |
链上数据核对于 on-chain data checked 2026-10-20
其他错误码:-3 ERROR_SYSCALL,-21 ERROR_SCRIPT_TOO_LONG(来自 simple_udt.c)Other error codes: -3 ERROR_SYSCALL, -21 ERROR_SCRIPT_TOO_LONG (from simple_udt.c)