CrowdCell Pledge Lock 约束CrowdCell Pledge Lock Constraints
来源:alesfer001/CrowdCell / contracts/pledge-lock/src/main.rs@2fd13f6 · 0xc28d…a525 (data2,仅测试网) · 社区合约,未经独立审计Source: alesfer001/CrowdCell / contracts/pledge-lock/src/main.rs@2fd13f6 · 0xc28d…a525 (data2, testnet only) · community contract, not independently audited
CrowdCell · CKB 上全有或全无的众筹(测试网预览)All-or-nothing crowdfunding on CKB (testnet preview)
- 官网Websitecrowdcell.vercel.app
- GitHubGitHubgithub.com/alesfer001/CrowdCell
- Nervos Talk 帖子Nervos Talk threadtalk.nervos.org/t/introducing-ckb-kickstarter-decentralized-all-or-nothing-crowdfunding-on-nervos-ckb-testnet-mvp-live/10130
- Nervos Talk 作者Nervos Talk authortalk.nervos.org/u/Ayoub_Lesfer
- XXx.com/crowdcellckb
作者:Author: Ayoub Lesfer (GitHub alesfer001, Nervos Talk Ayoub_Lesfer)
来源:Source: CrowdCell README @2fd13f6; Nervos Talk /t/10130 created by Ayoub_Lesfer
A截止前:合并(since = 0)Before deadline: merge (since = 0)
Inputs 输入Inputs
≥2 个 pledge≥2 pledgesCell{ lock: { codeHash: PLEDGE_LOCK, args: campaign_hash 32B ‖ deadline 8B ‖ backer_lock_hash 32B }, type: T, data[64..72] = aᵢ }, since = 0
➜
Outputs 输出Outputs
唯一合并 cellsingle merged cellCell{ lock: 同一 lock, capacity = Σ输入, type: T, data[64..72] = Σaᵢ }Cell{ lock: same lock, capacity = Σinputs, type: T, data[64..72] = Σaᵢ }
lock args 字节布局(72B)lock args byte layout (72B)
campaign_type_script_hash32B
deadline_block8B
backer_lock_hash32B
- campaign_type_script_hash 32B 所属 campaign 的 type script hashtype script hash of the campaign 在 cell_deps 中查找looked up in cell_deps
- deadline_block 8B 截止区块 u64 LEdeadline block u64 LE since ≥ 它since ≥ it (13)
- backer_lock_hash 32B 认捐人 lock hashbacker lock hash 退款 / 找零去向refund / overhead destination (32)
限制Constraints
- args ≥ 72 字节≥ 72 bytes (10)
- inputs:: group 输入 ≥ 2≥ 2 group inputs (40)
- outputs:: 恰好 1 个同 lock 输出(0 个 → 41,多个 → 42)exactly one output with the same lock (none → 41, several → 42) (41 / 42)
- capacity:: 输出 capacity = Σ输入 capacity(合并不扣手续费)output capacity = Σ input capacity (no fee taken) (43)
- type:: 所有输入与输出 type 相同且非空all inputs and the output share one non-empty type (45)
- data:: 输入、输出 data ≥ 72 字节且 amount 之和相等input/output data ≥ 72 bytes and amounts sum equal (46)
- u64:: 累加溢出addition overflows (33)
B截止后 + Success:释放给创建者After deadline + Success: release to creator
Inputs 输入Inputs
pledge(s)同一 lock 的 pledge,since = 绝对区块号 ≥ deadlinepledges with this lock, since = absolute block ≥ deadline
cell_depcampaign Cell{ type hash = campaign_hash, data[56] = 1 Success }
➜
Outputs 输出Outputs
创建者creatorΣ Cell{ lock hash = creator_lock_hash } ≥ Σamount
认捐人backerΣ Cell{ lock hash = backer_lock_hash } ≥ Σcapacity − Σamount − 1 CKB
限制Constraints
- since:: 非 0 时必须绝对、标志合法、按区块号when non-zero must be absolute, valid flags, block number (12)
- since:: 区块号 ≥ deadline_blockblock number ≥ deadline_block (13)
- cell_dep:: campaign 状态为 Active 则拒绝rejected while the campaign is Active (20)
- inputs:: 不得同时花费另一个 pledge-lock group(同 code_hash、不同 args)no other pledge-lock group (same code_hash, other args) may be spent (34)
- outputs:: 给创建者 ≥ Σamount,给认捐人 ≥ 剩余 − 1 CKB;创建者即认捐人时合计 ≥ Σcapacity − 1 CKBcreator ≥ Σamount, backer ≥ overhead − 1 CKB; if creator = backer, total ≥ Σcapacity − 1 CKB (32)
- u64:: 累加溢出addition overflows (33)
C截止后 + Failed(或宽限期后无 cell_dep):退款After deadline + Failed (or no cell_dep after grace): refund
Inputs 输入Inputs
pledge(s)since ≥ deadline;cell_dep 中 campaign 为 Failed,或缺失且 since ≥ deadline + 1,944,000since ≥ deadline; campaign in cell_deps is Failed, or absent and since ≥ deadline + 1,944,000
➜
Outputs 输出Outputs
认捐人backerΣ Cell{ lock hash = backer_lock_hash } ≥ Σcapacity − 1 CKB
限制Constraints
- cell_dep:: 找不到 campaign cell_dep 且未过宽限期campaign cell_dep missing and grace period not over (21)
- inputs:: 不得同时花费另一个 pledge-lock groupno other pledge-lock group may be spent (34)
- outputs:: 给 backer_lock_hash ≥ Σcapacity − 1 CKBto backer_lock_hash ≥ Σcapacity − 1 CKB (32)
部署与来源Deployments & source 未核验unverified
源码source alesfer001/CrowdCell@2fd13f6b · contracts/pledge-lock/src/main.rs (main HEAD read 2026-10-22; author Ayoub_Lesfer (Nervos Talk) offered CrowdCell in https://talk.nervos.org/t/11014/2. Testnet only; deployment from README / deployment/deployed-contracts-testnet.json, hash_type data2 from off-chain/frontend/src/lib/constants.ts)
二进制核验binary check 未核验unverified hash appears in the repo only as a deployment record or doc, which does not prove the recorded commit builds this binary (reproducible build not attempted)
0xc28d8042a1…6ae3a525: listed in README.md; listed in deployment/deployed-contracts-devnet.json; listed in deployment/deployed-contracts-testnet.json
0xc28d8042a1…6ae3a525: listed in README.md; listed in deployment/deployed-contracts-devnet.json; listed in deployment/deployed-contracts-testnet.json
| 网络network | code_hash | cell_dep | type_id args | 数据哈希data hash | 部署交易deploy tx |
|---|---|---|---|---|---|
| testnet | 0xc28d8042a1cf39d02db0cbc769a26faad80b39563c2d2de40536ddb66ae3a525 data2 | 0x1dc0f07d3a…c0a0beb2:0 code | — | 0xc28d8042a1…6ae3a525 | 0x1dc0f07d3a…c0a0beb2 #22448251 |
链上数据核对于 on-chain data checked 2026-10-22
错误码(main.rs):10 INVALID_ARGS · 11 LOAD_SINCE · 12 INVALID_SINCE · 13 SINCE_BELOW_DEADLINE · 20 CAMPAIGN_STILL_ACTIVE · 21 CAMPAIGN_CELL_DEP_MISSING · 30 LOAD_CAPACITY · 31 LOAD_LOCK_HASH · 32 INSUFFICIENT_OUTPUT · 33 OVERFLOW · 34 MIXED_PLEDGE_INPUTS · 40 NOT_A_MERGE · 41 NO_MERGE_OUTPUT · 42 MULTIPLE_MERGE_OUTPUTS · 43 MERGE_CAPACITY_MISMATCH · 44 MERGE_LOCK_MISMATCH · 45 MERGE_TYPE_MISMATCH · 46 MERGE_AMOUNT_MISMATCHError codes (main.rs): 10 INVALID_ARGS · 11 LOAD_SINCE · 12 INVALID_SINCE · 13 SINCE_BELOW_DEADLINE · 20 CAMPAIGN_STILL_ACTIVE · 21 CAMPAIGN_CELL_DEP_MISSING · 30 LOAD_CAPACITY · 31 LOAD_LOCK_HASH · 32 INSUFFICIENT_OUTPUT · 33 OVERFLOW · 34 MIXED_PLEDGE_INPUTS · 40 NOT_A_MERGE · 41 NO_MERGE_OUTPUT · 42 MULTIPLE_MERGE_OUTPUTS · 43 MERGE_CAPACITY_MISMATCH · 44 MERGE_LOCK_MISMATCH · 45 MERGE_TYPE_MISMATCH · 46 MERGE_AMOUNT_MISMATCH
只读取第一个 group 输入的 since 决定路径;since = 0 走合并路径,但并不证明当前区块早于截止(源码注释:合并输出仍是同一 lock)Only the first group input's since picks the path; since = 0 takes the merge path but does not prove the chain is before the deadline (source comment: the merged output keeps the same lock)
释放 / 退款时每个 pledge 的 amount 取 data[64..72](> capacity 或 data < 72B 时按整个 capacity 计)On release/refund each pledge's amount is data[64..72] (the whole capacity if it exceeds capacity or data < 72 B)
cell_dep 中的 campaign 若 data 无法解析,按“缺失”处理(走宽限期分支)A campaign cell_dep whose data cannot be parsed is treated as missing (grace-period branch)
不检查任何签名:任何人都可以构造释放 / 退款交易(README:结算机器人或任何人)No signature is checked: anyone may build release/refund (README: finalization bot or anyone)
解码器限制:交易页不解析 cell_deps 的数据,因此 campaign 状态与释放分支显示为未检查Decoder limitation: the tx page does not resolve cell_dep data, so campaign status and the release branch show as not checked
只读取第一个 group 输入的 since 决定路径;since = 0 走合并路径,但并不证明当前区块早于截止(源码注释:合并输出仍是同一 lock)Only the first group input's since picks the path; since = 0 takes the merge path but does not prove the chain is before the deadline (source comment: the merged output keeps the same lock)
释放 / 退款时每个 pledge 的 amount 取 data[64..72](> capacity 或 data < 72B 时按整个 capacity 计)On release/refund each pledge's amount is data[64..72] (the whole capacity if it exceeds capacity or data < 72 B)
cell_dep 中的 campaign 若 data 无法解析,按“缺失”处理(走宽限期分支)A campaign cell_dep whose data cannot be parsed is treated as missing (grace-period branch)
不检查任何签名:任何人都可以构造释放 / 退款交易(README:结算机器人或任何人)No signature is checked: anyone may build release/refund (README: finalization bot or anyone)
解码器限制:交易页不解析 cell_deps 的数据,因此 campaign 状态与释放分支显示为未检查Decoder limitation: the tx page does not resolve cell_dep data, so campaign status and the release branch show as not checked