CrowdCell Receipt 类型脚本 约束CrowdCell Receipt Type Script Constraints
来源:alesfer001/CrowdCell / contracts/receipt/src/main.rs@2fd13f6 · 0x2bac…a575 (data2,仅测试网) · 社区合约,未经独立审计Source: alesfer001/CrowdCell / contracts/receipt/src/main.rs@2fd13f6 · 0x2bac…a575 (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 receipt with a pledge
Inputs 输入Inputs
—无 group 输入no group input
➜
Outputs 输出Outputs
receiptCell{ type: { codeHash: RECEIPT, args: pledge_code_hash 32B }, data(80B): amount ‖ backer ‖ campaign_hash ‖ deadline }
pledgetype code_hash = args[0..32] 的第一个 data ≥ 72B 的输出first output with type code_hash = args[0..32] and data ≥ 72B
receipt data 字节布局(创建时 80B)receipt data byte layout (80B at creation)
pledge_amount8B
backer_lock_hash32B
campaign_type_hash32B
deadline_block8B
- pledge_amount 8B 认捐额 u64 LEpledge amount u64 LE > 0;= pledge amount> 0; = pledge amount (12 / 21)
- backer_lock_hash 32B 认捐人 lock hashbacker lock hash 非零;= pledge data[32..64]non-zero; = pledge data[32..64] (13 / 22)
- campaign_type_hash 32B campaign type script hashcampaign type script hash = pledge lock args[0..32]= pledge lock args[0..32] (24)
- deadline_block 8B 截止区块 u64 LEdeadline u64 LE = pledge lock args[32..40]= pledge lock args[32..40] (24)
限制Constraints
- args ≥ 32 字节≥ 32 bytes (20)
- data ≥ 80 字节(< 40 也报 10)≥ 80 bytes (< 40 also 10) (10)
- pledge_amount > 0> 0 (12)
- backer_lock_hash:: ≠ 0≠ 0 (13)
- pledge:: 输出中存在匹配的 pledge cella matching pledge cell exists in outputs (14)
- amount = pledge data[64..72]= pledge data[64..72] (21)
- backer = pledge data[32..64]= pledge data[32..64] (22)
- campaign:: pledge lock args ≥ 72B,且 [0..32] / [32..40] 与 receipt 一致pledge lock args ≥ 72B and [0..32] / [32..40] match the receipt (24)
1 → 0销毁回执取回押金Destroy receipt to reclaim its deposit
Inputs 输入Inputs
receiptdata ≥ 40B;80B 版本含 campaign 字段data ≥ 40B; the 80B form carries campaign fields
➜
Outputs 输出Outputs
认捐人backercampaign 已结算时任意;否则需同时消耗 pledge 且有一个给 backer 的输出 capacity ≥ amount − 1 CKBany once the campaign is settled; otherwise a pledge must be consumed and one backer output has capacity ≥ amount − 1 CKB
限制Constraints
- data ≥ 40 字节≥ 40 bytes (10)
- settled:: (80B 版本)cell_deps 中有该 campaign 且 status ≠ 0,或 since 为绝对区块号 ≥ deadline + 1,944,000 → 直接通过(80B form) campaign in cell_deps with status ≠ 0, or since absolute block ≥ deadline + 1,944,000 → passes (—)
- inputs:: 否则输入中须有 type code_hash = args[0..32] 的 pledgeotherwise an input with type code_hash = args[0..32] (pledge) is required (23)
- args ≥ 32 字节≥ 32 bytes (20)
- outputs:: 存在单个 lock hash = backer 的输出 capacity ≥ amount − 1 CKBa single output with lock hash = backer has capacity ≥ amount − 1 CKB (15)
1 → 1修改Modify
Inputs 输入Inputs
receipt…
➜
Outputs 输出Outputs
receipt…
限制Constraints
- group:: 不允许not allowed (11)
部署与来源Deployments & source 未核验unverified
源码source alesfer001/CrowdCell@2fd13f6b · contracts/receipt/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)
0x2bac36d4ca…87dba575: listed in README.md; listed in deployment/deployed-contracts-devnet.json; listed in deployment/deployed-contracts-testnet.json
0x2bac36d4ca…87dba575: 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 | 0x2bac36d4cadd65b66c25557d37c2bba4f7e3c40a94ca92f3853b311887dba575 data2 | 0x63d545b60d…e317b967:0 code | — | 0x2bac36d4ca…87dba575 | 0x63d545b60d…e317b967 #22448254 |
链上数据核对于 on-chain data checked 2026-10-22
错误码(main.rs):9 LOAD_DATA · 10 INVALID_RECEIPT_DATA · 11 RECEIPT_MODIFICATION_NOT_ALLOWED · 12 ZERO_PLEDGE_AMOUNT · 13 ZERO_BACKER_HASH · 14 NO_MATCHING_PLEDGE · 15 REFUND_OUTPUT_MISSING · 16 LOAD_LOCK · 17 LOAD_CAPACITY · 18 LOAD_LOCK_HASH · 19 LOAD_SCRIPT · 20 INVALID_ARGS · 21 AMOUNT_MISMATCH · 22 BACKER_MISMATCH · 23 NO_PLEDGE_CONSUMED · 24 CAMPAIGN_MISMATCH · 25 LOAD_SINCEError codes (main.rs): 9 LOAD_DATA · 10 INVALID_RECEIPT_DATA · 11 RECEIPT_MODIFICATION_NOT_ALLOWED · 12 ZERO_PLEDGE_AMOUNT · 13 ZERO_BACKER_HASH · 14 NO_MATCHING_PLEDGE · 15 REFUND_OUTPUT_MISSING · 16 LOAD_LOCK · 17 LOAD_CAPACITY · 18 LOAD_LOCK_HASH · 19 LOAD_SCRIPT · 20 INVALID_ARGS · 21 AMOUNT_MISMATCH · 22 BACKER_MISMATCH · 23 NO_PLEDGE_CONSUMED · 24 CAMPAIGN_MISMATCH · 25 LOAD_SINCE
创建时只检查第一个 group 输出与找到的第一个 pledge 输出Creation checks only the first group output and the first pledge output found
receipt 只保护押金,不能凭它取走认捐资金A receipt only guards its own deposit; it cannot release pledged funds
解码器限制:cell_deps 数据不解析,“已结算”分支显示为未检查Decoder limitation: cell_dep data is not resolved, so the settled branch shows as not checked
创建时只检查第一个 group 输出与找到的第一个 pledge 输出Creation checks only the first group output and the first pledge output found
receipt 只保护押金,不能凭它取走认捐资金A receipt only guards its own deposit; it cannot release pledged funds
解码器限制:cell_deps 数据不解析,“已结算”分支显示为未检查Decoder limitation: cell_dep data is not resolved, so the settled branch shows as not checked