CrowdCell Pledge 类型脚本 约束CrowdCell Pledge Type Script Constraints
来源:alesfer001/CrowdCell / contracts/pledge/src/main.rs@2fd13f6 · 0xe45d…b024 (data2,仅测试网) · 社区合约,未经独立审计Source: alesfer001/CrowdCell / contracts/pledge/src/main.rs@2fd13f6 · 0xe45d…b024 (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
0 → 1创建认捐Create pledge
Inputs 输入Inputs
—无 group 输入no group input
➜
Outputs 输出Outputs
pledgeCell{ type: { codeHash: PLEDGE, args: receipt_code_hash 32B? }, data: campaign_id≠0 ‖ backer_lock_hash≠0 ‖ amount>0 }
pledge data 字节布局(72B)pledge data byte layout (72B)
campaign_id32B
backer_lock_hash32B
amount8B
- campaign_id 32B campaign 标识(信息性)campaign id (informational) 非零;合并 / 部分退款时一致non-zero; equal on merge / partial refund (3)
- backer_lock_hash 32B 认捐人 lock hashbacker lock hash 非零non-zero (4)
- amount 8B 认捐额 u64 LEamount u64 LE > 0> 0 (5)
限制Constraints
- data ≥ 72 字节(只检查第一个 group 输出)≥ 72 bytes (only the first group output is checked) (1)
- campaign_id:: ≠ 0≠ 0 (3)
- backer_lock_hash:: ≠ 0≠ 0 (4)
- amount > 0> 0 (5)
n → 1合并(≥2 输入 → 1 输出)Merge (≥2 inputs → 1 output)
Inputs 输入Inputs
pledgesdata: campaign_id ‖ … ‖ aᵢ
➜
Outputs 输出Outputs
pledgedata: campaign_id ‖ … ‖ Σaᵢ
限制Constraints
- data:: 每个 data ≥ 72 字节every data ≥ 72 bytes (1)
- campaign_id:: 所有输入与输出相同same in every input and the output (11)
- amount:: 输出 amount = Σ输入output amount = Σ inputs (12)
- u64:: 累加溢出addition overflows (13)
1 → 1部分退款(金额减少)Partial refund (amount decreases)
Inputs 输入Inputs
pledgedata: campaign_id ‖ … ‖ a
receipttype code_hash = args[0..32] 的 cell,data[0..8] = a − a′cell whose type code_hash = args[0..32], data[0..8] = a − a′
➜
Outputs 输出Outputs
pledgedata: campaign_id ‖ … ‖ a′ < a
限制Constraints
- campaign_id:: 输入输出相同input and output equal (14)
- amount:: 输出 amount < 输入 amountoutput amount < input amount (15)
- receipt:: args ≥ 32 字节时:输入中第一个(data ≥ 8B 的)receipt 金额 = 差值when args ≥ 32 bytes: first receipt input (data ≥ 8B) amount = difference (16)
- receipt:: args ≥ 32 字节时输入中必须有 receiptwhen args ≥ 32 bytes a receipt must be in inputs (17)
1 → 0销毁Destroy
Inputs 输入Inputs
pledge任意any
➜
Outputs 输出Outputs
—无 group 输出no group output
限制Constraints
- —:: 总是允许(资金去向由 pledge-lock 约束)always allowed (routing enforced by pledge-lock) (—)
m → k其他形状Other shapes
Inputs 输入Inputs
pledgesm
➜
Outputs 输出Outputs
pledgesk
限制Constraints
- group:: 既非 n→1(n≥2)也非 1→1neither n→1 (n≥2) nor 1→1 (10)
部署与来源Deployments & source 未核验unverified
源码source alesfer001/CrowdCell@2fd13f6b · contracts/pledge/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 and on-chain usage)
二进制核验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)
0xe45d09f08d…ae8eb024: listed in README.md; listed in deployment/deployed-contracts-devnet.json; listed in deployment/deployed-contracts-testnet.json
0xe45d09f08d…ae8eb024: 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 | 0xe45d09f08d0e842340afb004cfb6b6b6414ad387f9cd2f3e0b9abcd6ae8eb024 data2 | 0xcf0d6069aa…2fdb33cf:0 code | — | 0xe45d09f08d…ae8eb024 | 0xcf0d6069aa…2fdb33cf #22448248 |
链上数据核对于 on-chain data checked 2026-10-22
错误码(main.rs):1 data 过短 · 3 campaign_id=0 · 4 backer=0 · 5 amount=0 · 7 NO_SCRIPT · 9 LOAD_DATA · 10 MODIFICATION_NOT_ALLOWED · 11 MERGE_DIFFERENT_CAMPAIGNS · 12 MERGE_AMOUNT_MISMATCH · 13 OVERFLOW · 14 CAMPAIGN_MISMATCH · 15 PARTIAL_REFUND_INVALID · 16 REFUND_AMOUNT_MISMATCH · 17 NO_RECEIPT_IN_INPUTSError codes (main.rs): 1 data too short · 3 campaign_id=0 · 4 backer=0 · 5 amount=0 · 7 NO_SCRIPT · 9 LOAD_DATA · 10 MODIFICATION_NOT_ALLOWED · 11 MERGE_DIFFERENT_CAMPAIGNS · 12 MERGE_AMOUNT_MISMATCH · 13 OVERFLOW · 14 CAMPAIGN_MISMATCH · 15 PARTIAL_REFUND_INVALID · 16 REFUND_AMOUNT_MISMATCH · 17 NO_RECEIPT_IN_INPUTS
type args 可选:≥ 32 字节时前 32 字节为 receipt 合约 code_hash;不足 32 字节则部分退款不要求 receipttype args optional: when ≥ 32 bytes the first 32 are the receipt code_hash; shorter args mean partial refunds need no receipt
创建时只检查第一个 group 输出,合并时只读第一个 group 输出Creation checks only the first group output; merge reads only the first group output
pledge 是否计入 campaign 由 campaign 类型脚本按 pledge-lock 判断,与本脚本无关Whether a pledge counts toward a campaign is decided by the campaign type script via pledge-lock, not here
type args 可选:≥ 32 字节时前 32 字节为 receipt 合约 code_hash;不足 32 字节则部分退款不要求 receipttype args optional: when ≥ 32 bytes the first 32 are the receipt code_hash; shorter args mean partial refunds need no receipt
创建时只检查第一个 group 输出,合并时只读第一个 group 输出Creation checks only the first group output; merge reads only the first group output
pledge 是否计入 campaign 由 campaign 类型脚本按 pledge-lock 判断,与本脚本无关Whether a pledge counts toward a campaign is decided by the campaign type script via pledge-lock, not here