Tags: CKB, dApp, Infrastructure, Dev Tool, Smart Contract, SDK, CLI, Capacity Leasing, Cell Model, Type Script, Lock Script
1. Project Overview
Cellar is a CKB-native capacity leasing protocol that lets idle CKB holders lease cell capacity to developers and applications for a bounded term.
CKB since is not a property of a live cell. It is a field on CellInput, meaning it constrains a specific spend transaction. Also, CKB cells are immutable, so borrower “writes” must consume the current lease cell and create a valid successor cell.
This revised proposal restructures Cellar as a covenant-style lease state machine:
- Providers lease CKB capacity without giving up principal ownership.
- Borrowers update leased data through controlled
1 input -> 1 outputsuccessor transitions. - Immutable lease terms are preserved across every successor.
- The provider can reclaim the current live lease cell after an absolute expiry using
since. - Transaction fees are paid from separate inputs so provider principal is not silently drained.
- Cellar v0 is honest about its guarantees: principal safety plus unilateral provider reclaim after expiry, not a magical cell-level timer.
The funded MVP will produce CKB scripts, tests, TypeScript SDK helpers, CLI commands, and a testnet demo showing lease creation, borrower update, expiry, and provider reclaim.
2. Team Profile
Applicant / lead: Carlos
Role: Protocol design, CKB script implementation, TypeScript SDK, CLI, testnet deployment, and demo integration.
Contact: [email protected]
Relevant background: CKB application/protocol development, Rust smart contract work, TypeScript tooling, and dApp prototyping.
3. Project Background
CKB capacity is a scarce on-chain resource. Many CKB holders have idle capacity, while developers need temporary capacity for app data, metadata, indexable references, registries, or other application state.
Cellar creates a market between:
- Capacity providers, who want yield while preserving their CKB principal.
- Borrowers/developers, who want temporary cell capacity without permanently buying all required CKB up front.
The main technical challenge is not marketplace UX. It is correctly expressing a safe lease inside CKB’s cell model.
The revised design is based on these confirmed CKB semantics:
| Confirmed fact | Design consequence |
|---|---|
| Live cells are consumed as inputs and new cells are created as outputs. | Borrower updates must recreate a successor lease cell. |
since exists on CellInput, not CellOutput. |
Expiry must be stored in lease data/script args and checked when spending. |
since is a lower-bound validity precondition. |
It enforces “not before expiry” for provider reclaim, but not “borrower can never update after expiry.” |
| Lock scripts authorize spending input cells. Type scripts enforce state rules over matching inputs/outputs. | Cellar needs both a lock script and a type-script covenant. |
| A cell has one type-script slot. | The leased cell cannot safely carry arbitrary borrower-supplied type scripts in v0. |
4. Proposed Solution
Cellar v0 will implement a direct lease primitive first, then keep the marketplace offer layer as a follow-up once the core covenant is proven.
The active lease cell will look like this:
LeaseCell
capacity: principal_capacity
lock: CellarLeaseLock(lease_id, provider_auth, borrower_auth)
type: CellarLeaseType(lease_id)
data: LeaseData
LeaseData will be versioned and Molecule-encoded:
LeaseData {
version: uint8,
lease_id: Byte32,
provider_payout_lock_hash: Byte32,
borrower_lock_hash: Byte32,
principal_capacity: uint64,
expiry_since: uint64,
max_data_bytes: uint32,
terms_hash: Byte32,
payload: Bytes
}
The lease type script enforces the covenant. The lease lock script verifies the authorized party and mode.
Core Flows
Create lease
- Provider capacity inputs fund one active
LeaseCell. - Borrower pays rent to provider according to agreed terms.
- The lease cell stores immutable terms, absolute expiry, capacity, and initial payload.
Borrower update
- Borrower spends the current lease cell.
- Transaction creates exactly one valid successor lease cell.
- The successor preserves lease ID, provider payout lock hash, borrower lock hash, principal capacity, expiry, maximum data size, terms hash, lock script, and type script.
- Only
payloadchanges. - Fees are paid from borrower-owned non-lease inputs.
Provider reclaim
- Provider spends the current live lease cell after expiry.
- The reclaim transaction input uses absolute
since = expiry_since. - The type script requires a provider payout output with at least
principal_capacity. - Fees are paid from separate provider/keeper inputs.
Mutual early close
- Optional v0 path.
- Requires both provider and borrower authorization.
- Still requires provider principal payout.
5. Technical Approach
Contract Architecture
Cellar v0 will include two CKB scripts:
-
cellar-lease-type- Enforces creation, update, and reclaim state transitions.
- Preserves lease invariants across borrower updates.
- Rejects changed terms, changed scripts, missing successor cells, multiple successors, principal leakage, and relative expiry values.
-
cellar-lease-lock- Verifies witness mode and signatures.
- Supports borrower update, provider reclaim, and optional mutual close modes.
- Delegates state correctness to
cellar-lease-type.
The revised design no longer treats since as a lease property of a cell. Instead:
expiry_sinceis stored as immutable lease data.- Provider reclaim uses
sinceon the reclaim transaction input. - Borrower updates are modeled as successor-cell transitions.
- The type script forces every successor to preserve the same expiry and reclaim path.
This means a provider cannot reclaim before expiry, and after expiry the provider can reclaim whichever successor lease cell is currently live.
Expiry Guarantee
Cellar v0 will not claim that non-interactive borrower updates are impossible after expiry. CKB has a lower-bound since field, but no native upper-bound field for “this transaction is valid only before X.”
Therefore the honest v0 guarantee is:
Cellar v0 is principal-safe and supports unilateral provider reclaim after absolute expiry. A watcher/keeper should monitor active leases and submit reclaim transactions as soon as expiry is reached.
If strict prevention of borrower updates after expiry is required, it must be implemented with an additional mechanism such as provider co-signing, a clock/oracle cell, or time-window permission tickets. That stricter design is outside the v0 MVP unless reviewers request it as a scope change.
Tooling
- CKB scripts: Rust targeting CKB-VM.
- Data encoding: Molecule.
- SDK and CLI: TypeScript.
- Testing: CKB script test suite covering valid and adversarial transitions.
- Demo: testnet lease lifecycle with transaction hashes and CLI output.
Research Basis
The proposal relies on primary CKB docs and RFCs
A local probe also confirmed that CellInput has since, CellOutput does not, and absolute/relative since values encode differently.
6. To-Do List
Week 1: Specification and Script Skeleton
- Finalize Molecule schema for
LeaseDataand witness modes. - Define exact
lease_idderivation. - Implement
cellar-lease-typeskeleton. - Implement
cellar-lease-lockskeleton. - Add baseline creation/update/reclaim tests.
Week 2: Covenant Rules and Adversarial Tests
- Enforce borrower update invariants.
- Enforce provider reclaim payout and absolute
since. - Add tests for changed terms, changed scripts, missing successor, duplicate successor, principal leakage, relative expiry, and oversized payload.
- Measure and document cycle costs.
Week 3: TypeScript SDK and CLI
- Build SDK transaction helpers:
- create lease;
- update payload;
- reclaim after expiry;
- parse lease cells;
- build watcher queries.
- Build CLI commands:
cellar lease create;cellar lease update;cellar lease reclaim;cellar lease watch.
Week 4: Testnet Demo and Documentation
- Deploy scripts on CKB testnet.
- Run sample direct lease lifecycle.
- Publish testnet transaction hashes.
- Create demo using leased payload data for NFT metadata or registry data.
- Write README, usage guide, and limitation notes.
7. Funding Requested
Requested amount: $1,000
Estimated duration: 4 weeks
Funding use:
- CKB script development.
- Test suite and adversarial validation.
- TypeScript SDK and CLI.
- Testnet deployment.
- Demo app and documentation.
8. Deliverables & How to Verify Them
Deliverable 1: Formal Cellar v0 Specification
Contents
- Lease state machine.
- Molecule schema.
- Script args and witness formats.
- Absolute
sincepolicy. - Security invariants and known limitations.
Verification
- Reviewer can inspect the spec and confirm it does not treat
sinceas a cell property. - Reviewer can confirm borrower updates are defined as successor transitions.
- Reviewer can confirm strict post-expiry borrower freeze is not overclaimed.
Deliverable 2: CKB Scripts
Contents
cellar-lease-type.cellar-lease-lock.
Verification
- Build scripts from source.
- Run local tests.
- Confirm invalid transactions fail for:
- relative expiry;
- changed provider payout lock;
- changed expiry;
- changed principal;
- missing successor;
- duplicate successor;
- changed lock/type scripts;
- reclaim before expiry;
- reclaim payout below principal.
Deliverable 3: Test Suite
Contents
- Creation tests.
- Borrower update tests.
- Provider reclaim tests.
- Mutual close tests if included.
- Adversarial tests.
Verification
- Reviewer runs test command from README.
- Test output shows all valid cases passing and invalid cases rejected.
- Cycle budget report is included.
Deliverable 4: TypeScript SDK
Contents
- Transaction builders for lease creation, payload update, and reclaim.
- Lease cell parser.
- Watcher helper for expiring leases.
Verification
- Example script creates a valid transaction skeleton.
- SDK examples are used by CLI and demo.
Deliverable 5: CLI
Contents
cellar lease create.cellar lease update.cellar lease reclaim.cellar lease watch.
Verification
- CLI can create, update, and reclaim a testnet lease.
- CLI outputs transaction hashes and parsed lease state.
Deliverable 6: Testnet Deployment and Demo
Contents
- Deployed scripts.
- Sample testnet lease cells.
- Demo showing borrower update and provider reclaim.
Verification
- Reviewer can inspect published testnet transaction hashes.
- Demo README includes commands and expected results.
- Early reclaim rejection is verified by local tests, because invalid transactions are not accepted on-chain.
9. Current State vs Funded Work
Current State
- Original forum idea exists.
- Matt’s feedback has been reviewed.
- CKB docs and RFCs have been checked.
- The design has been restructured around CKB’s actual cell and
sincesemantics. - A local Lumos v0.23.0 probe confirmed:
CellInputhassince;CellOutputdoes not havesince;- absolute and relative
sincevalues encode differently.
Funded Work
The requested funding covers the implementation and validation of the revised v0 design:
- Production-quality script prototype.
- Complete tests.
- SDK and CLI.
- Testnet deployment.
- Demo and documentation.
The marketplace offer book is intentionally deferred until the direct lease primitive is proven.
10. CKB Alignment
Cellar is directly aligned with CKB because it builds on CKB’s unique cell model and capacity economics.
It supports CKB by:
- Increasing the utility of idle CKB capacity.
- Creating a new primitive for temporary on-chain storage and app data.
- Giving developers a way to use capacity without permanently acquiring all of it up front.
- Demonstrating safe covenant-style state transitions on CKB.
- Producing reusable SDK and CLI tooling for future CKB applications.
- Making the distinction between lock scripts, type scripts, cells, inputs, outputs, and
sinceclearer for builders.
