CellScript 0.33 Alpha: A Major Step Forward for CellScript Contracts
CellScript 0.33.0-alpha.1 is out, and #47, #48, #49 are now closed.
This is one of the largest steps forward CellScript has taken. The release brings together the work since 0.31, including the intervening 0.32 development work. It opens up a much wider range of contracts we can write on CKB, and it needs more time in real applications.
That is why this is an alpha. The feature set is now frozen. The next stage is to test, simplify, repair and consolidate what we have.
The first roadmap section now has an initial implementation
The first section of the CellScript roadmap described the language and runtime foundations for more ambitious applications. It covered different kinds of Cells, richer data, temporary accounting and reusable contract components. All five workstreams in that section now have an initial implementation: #28, #29, #47, #48, #49.
That is a major milestone. It gives us a more complete set of building blocks for exploring the financial protocols in the rest of the roadmap. Custody, pricing, liquidity positions and settlement rules remain substantial application work ahead.
Here is what the new design space looks like:
| Building block | What 0.33 adds to the 0.31 foundations | What a contract author can explore | Related work |
|---|---|---|---|
| Different Cell roles | Name and select bounded groups with different Script identities, then match their inputs and outputs | Mixed-asset settlement and coordinated updates across several kinds of state | #49 |
| Richer data | Describe bounded lists of messages or records with variable-length content | Batch plans, document histories and state migrations with meaningful payloads | #48 |
| Temporary collections | Use bounded Vec, Map and Set workspaces with reusable read-only helpers | Totals by asset, duplicate detection and transaction-local accounting | #47 |
| Reusable components | Select approved implementations and permitted configurations while retaining the chosen instance’s identity | Applications with different issuers, owners or pool configurations | #28, #29, #80 |
| ZK applications | Bind proofs to actual state transitions, coordinate several state Cells and manage authorized verifier/key changes | Applications whose proof, transaction builder and state lifecycle work together | #22, #42, #44, #45, #46 |
These capabilities are already exercised by complete examples: multi-asset transfers, mixed settlement, byte-list migration and record-list migration.
What this looks like in a contract
Consider a transaction that moves several assets between several participants. We need to identify the relevant Cells, add up amounts for each asset, reject duplicate identifiers and check the final state. As the transaction grows, keeping those rules readable becomes a large part of the problem.
The following snippets are excerpts from the complete examples shipped with the alpha. Each source link includes the surrounding declarations and checks.
1. Accounting by asset, with ordinary collections
In the transfer example, the contract declares one temporary workspace and gives names to its accounting tables:
collections Totals {
limits { bytes: 4096, allocations: 4 }
incoming: OrderedMap<Hash, u128> { items: 32 }
outgoing: OrderedMap<Hash, u128> { items: 32 }
input_serials: OrderedSet<u64> { items: 32 }
output_serials: OrderedSet<u64> { items: 32 }
}
fn conserved(totals: &Totals) -> bool {
if totals.incoming.len() != totals.outgoing.len() { return false }
for (asset, amount) in totals.incoming {
if !totals.outgoing.contains_key(asset) { return false }
if totals.outgoing.get(asset) != amount { return false }
}
return true
}
The two Maps answer “how much of this asset comes in?” and “how much goes out?” The Sets detect repeated note identifiers. The conserved helper can read the workspace and compare the totals without taking it away from the caller.
Splitting one note into several, or merging several notes into one, can follow the same conservation rule. The spending contracts provide authorization, while this example checks the quantities recorded in its notes.
The full example reserves capacity using the actual input and output counts before filling these tables. That matters for how the workspace uses its budget.
2. State with a useful history
A contract can also describe a bounded history whose entries contain both an identity and variable-length content. The record migration example uses this declaration:
struct Message { revision: u64, payload: Vec<u8> }
data_shape Messages {
element: Message,
limits { items: 8, payload_bytes: 256, encoded_bytes: 2280 }
}
resource Document has store { messages: Messages, id: u64, revision: u64 }
resource Registry has store { id: u64, revision: u64 }
A document can carry up to eight messages, each with a revision and a bounded payload. The total encoding has its own limit. Ordinary field access and helpers can then express rules such as “preserve every existing message and append the new revision.”
Once the document and registry roles have been declared, the batch loop is short:
for i in 0..selected.documents.input_count() {
require migrate_document(selected.documents.input(i), selected.documents.successor(i), release_note[0], revision)
}
Here migrate_document checks the identity, revision, history, new message and capacity of each document. The selected successor is its matched output. This gives us a concrete starting point for coordinated updates to records with richer content.
3. Giving different participants clear roles
The settlement example describes orders and two asset roles. Its action starts with:
let selected = ckb::select_cell_roles<Settlement>()
let count = selected.orders.input_count()
require selected.base.input_count() == count * 2
require selected.quote.input_count() == count * 2
The code can talk about orders, base balances and quote balances directly. The role declarations identify which Cells belong to each role and how inputs correspond to outputs. The remaining logic checks each full fill and its payment legs.
On CKB, these participants validate the same candidate transaction. Each required contract must accept it:
flowchart TD
T["One candidate transaction"] --> S["Settlement rules"]
T --> A["Asset A rules"]
T --> B["Asset B rules"]
T --> L["Spending authorization"]
S --> C{"Every required Script accepts?"}
A --> C
B --> C
L --> C
C -->|Yes| V["Transaction is valid"]
C -->|No| R["Transaction is rejected"]
This is an important part of the design space: an application can organize several independently governed participants while keeping each participant’s responsibility visible. Reading another participant’s Cells does not give one contract authority over them.
The component-selection work in #28, #29, #80 extends this further. Applications can accept an implementation through a compatibility policy and allow specified configurations, while still binding the concrete instance used in the transaction. Two issuers or pools can share code and remain distinct participants.
Arena: a temporary workbench with a budget
An arena is a temporary workbench a contract opens while checking a transaction. Lists, accounting tables and sets can share its space. Their values share a lifetime, while persistent application state continues to live in Cells.
| Declaration | What it controls | How to think about it |
|---|---|---|
| Shared byte budget | The space charged to the whole workspace | The size of the workbench |
| Allocation budget | How many allocation events the workspace can make, including growth | How often new storage can be claimed |
| Member item limits | The maximum number of entries in each collection | The largest list or table that member may hold |
These limits work together. An item limit does not, by itself, guarantee that every collection can reach its maximum within the shared budget.
The current arena uses a simple allocation policy: it moves forward through its available space. When a collection grows into a larger buffer, the old buffer remains charged for that arena lifetime.
flowchart TD
W["Temporary workspace with a declared budget"] --> O["Collection uses a buffer for 4 items"]
O --> G["Collection needs more capacity"]
G --> N["Allocate a new buffer for 8 items"]
N --> M["Copy the existing values into the new buffer"]
M --> LIVE["Collection continues using the new buffer"]
M --> OLD["Old buffer is retired but still charged"]
LIVE --> BUDGET["Budget includes both allocations and bookkeeping"]
OLD --> BUDGET
BUDGET --> END["Owner lifetime ends; its temporary values stop being usable"]
Reserving the expected capacity up front avoids that growth history. The tools explain how the collections fit into their shared budget, including old buffers and allocation overhead. The arena is backed by reserved function-stack space, so its budget is also part of the contract’s stack use.
This gives us a straightforward resource model to inspect and test. More application experience will show where it is comfortable and where it needs improvement.
The wider journey from 0.31 to 0.33
The issue history helps show the breadth of this release. Some items add capabilities, some improve everyday writing, and others establish which implementation choices are actually worth adopting.
| Area | Closed issues | What the work contributed |
|---|---|---|
| Compatible components | #28, #29, #80 | Approved implementation selection, selected transaction participants and constrained configurations of distinct instances |
| Collections and richer transactions | #47, #48, #49 | Temporary accounting, bounded nested data and selection across different Cell roles |
| ZK applications and their lifecycle | #22, #42, #44, #45, #46 | The first application workflow, coordinated state updates, authorized key/verifier changes and measured proving and execution costs |
| Measuring and improving execution | #36, #37, #38, #39, #40, #41 | Actual stack measurements, code-size and cycle analysis, and comparisons of alternative implementations |
| Everyday contract writing | #50, #51 | Collection typing fixes and clearer bounded byte encoding, including lessons from updating AgoraSeal’s contracts |
The cost work also helped us reject changes whose measurements did not justify adopting them. Keeping an existing design after testing alternatives gives us a firmer basis for future decisions.
This release includes a substantial round of runtime repairs too: stack layouts, read lengths, error handling and preserving temporary values across helper calls. The current compiler test coverage records 2,445 passes, with detailed records included in the release. Broader use and security review will bring another necessary kind of feedback.
ZK collaboration and the next research direction
The ZK application work is especially relevant to what we can build next. A proof must be connected to the actual state and transaction it authorizes. The application also needs to handle a competing transaction and an approved change of verifier or key. Those paths now have concrete examples and tests.
This work has also benefited from my collaboration and discussions with Cecilia Mulandi (@Mulandi_Cecilia). Her groth16-ckb verifier, zk-Lock work and ZK research notes gave us concrete starting points for discussing how proofs should fit into real CKB applications. Our exchange about CellScript’s ZK design helped sharpen #22, especially the connection between a valid proof and the particular Cell transition it is allowed to authorize.
I will continue this collaboration, go deeper into the ZK design space, and share a more detailed exploration of Plonkish proof systems. I want to examine what they could make easier for application authors, how they compare with the current Groth16 path, and what proof creation and verification on CKB would cost in practice. This research will run alongside the consolidation of the frozen 0.33 feature set, with experiments and findings shared as the work develops.
A feature freeze, and a long odyssey to 0.34
All features are now frozen for this release cycle. APIs and implementation can still change as we simplify, repair and consolidate them. Ecosystem integration will continue around that fixed feature set.
I expect the journey from 0.33 to 0.34 to be a long odyssey. The first roadmap section now has its initial implementation; the next stage is to find out how well those capabilities hold up together.
| Alpha and beta priority | What it should improve for developers |
|---|---|
| Fully retire the early hash-buffer interfaces | Give ordinary bytes, exact slices and real hashes clear meanings |
| Retire separate optimisation levels and unify the compilation path | Provide one consistent path that we can test and explain thoroughly |
| Security auditing and regression fixes | Revisit older safety concerns with Guopeng and exercise combinations of the existing capabilities |
| Continue ZK collaboration and publish Plonkish research | Work further with Cecilia, explore the application tradeoffs of other proof systems, and share practical experiments alongside the frozen release work |
| Update the application examples | Show complete contracts using the current design, including the awkward cases |
| Update the toolchain and documentation | Make the language, builders, diagnostics and guides easier to use together |
| Collaborate with SSRI, IDL and CCC, including the discussion around Script IPC | Connect the current capabilities to the wider CKB ecosystem through clear interfaces and practical application workflows |
0.33 gives us much more to build with. I want to spend the next stage finding out how well it holds up: writing real contracts, making the examples easier to use, and working through the difficult cases that appear when these pieces meet. If you try the alpha, feedback on what is confusing, cumbersome or easy to misuse will be particularly valuable.