Write the transaction you expect. Ship the cell you can prove.

Describe CKB contracts as readable state changes. The compiler checks them, lowers them to on-chain artifacts, and keeps the metadata reviewers need — all from one source.

token.cell
1module cellscript::fungible_token;23const U64_MAX: u64 = 18446744073709551615;45resource Token has store, create, consume, replace, burn, relock {6    amount: u64,7    symbol: [u8; 8],8}910resource MintAuthority has store, create, replace {11    token_symbol: [u8; 8],12    max_supply: u64,13    minted: u64,14}1516action mint_with_authority(input auth_before: MintAuthority, witness to: Address, witness amount: u64,  output auth_after: MintAuthority,17output token: Token) {18    transition auth_before -> auth_after;19    require amount <= U64_MAX - auth_before.minted,20    "mint overflow";21    require auth_before.minted + amount <= auth_before.max_supply,22    "exceeds max supply";23    require auth_after.token_symbol == auth_before.token_symbol;24    require auth_after.max_supply == auth_before.max_supply;25    require auth_after.minted == auth_before.minted + amount;26    create token = Token {27        amount,28        symbol: auth_before.token_symbol,29    } with_lock(to)30}3132action transfer_token(input token: Token, witness to: Address,  output next_token: Token) {33    consume token;34    create next_token = Token {35        amount: token.amount,36        symbol: token.symbol,37    } with_lock(to)38}39// ... remaining source is available in the playground
1module cellscript::nft;23use cellscript::fungible_token::Token;45const U64_MAX: u64 = 18446744073709551615;67const MAX_SUPPLY: u64 = 10000;89const ROYALTY_BASIS_POINTS: u16 = 250;1011struct Metadata {12    name: String,13    description: String,14    image_uri: String,15    attributes: Vec<(String, String)>,16}1718resource NFT has store, create, consume, replace, burn, relock, read_ref {19    collection_id: Hash,20    token_id: u64,21    owner: Address,22    metadata_hash: Hash,23    royalty_recipient: Address,24    royalty_bps: u16,25}2627resource Collection has store, create, replace {28    name: String,29    symbol: String,30    creator: Address,31    total_supply: u64,32    max_supply: u64,33    base_uri: String,34}3536receipt Listing has create, consume, burn {37    collection_id: Hash,38    token_id: u64,39// ... remaining source is available in the playground
1module cellscript::amm_pool;23use cellscript::fungible_token::Token;45const U64_MAX: u64 = 18446744073709551615;67const MAX_FEE_RATE_BPS: u16 = 1000;89receipt LPReceipt has store, create, consume {10    pool_id: Hash,11    lp_amount: u64,12    provider: Address,13}1415shared Pool has store, create, replace {16    token_a_type: Hash,17    token_b_type: Hash,18    token_a_symbol: [u8; 8],19    token_b_symbol: [u8; 8],20    reserve_a: u64,21    reserve_b: u64,22    total_lp: u64,23    fee_rate_bps: u16,24}2526action seed_pool(input token_a: Token, input token_b: Token, witness fee_rate_bps: u16, witness provider: Address,  output pool: Pool,27output receipt: LPReceipt) {28    require (token_a.symbol != token_b.symbol),29    "same token";30    require (token_a.amount > 0) && (token_b.amount > 0),31    "zero liquidity";32    require (fee_rate_bps <= MAX_FEE_RATE_BPS),33    "fee too high";34    require (token_a.type_hash() != token_b.type_hash()),35    "same token type";36    require (token_a.amount <= U64_MAX / token_b.amount),37    "liquidity overflow";38    require (token_a.amount * token_b.amount < U64_MAX),39// ... remaining source is available in the playground
1module cellscript::vesting;23use cellscript::fungible_token::Token;45const U64_MAX: u64 = 18446744073709551615;67shared VestingConfig has store, create, read_ref {8    admin: Address,9    token_symbol: [u8; 8],10    cliff_period: u64,11    total_vesting_period: u64,12    revocable: bool,13}1415enum VestingState {16    Active,17    FullyClaimed,18}1920receipt VestingGrant has store, create, consume {21    state: VestingState,22    beneficiary: Address,23    total_amount: u64,24    claimed_amount: u64,25    grant_timepoint: u64,26    cliff_timepoint: u64,27    end_timepoint: u64,28    token_symbol: [u8; 8],29}3031flow VestingGrant.state {32    initial Active;33    terminal FullyClaimed;34    Active -> Active;35    Active -> FullyClaimed;36}3738action create_vesting_config(witness admin: Address, witness token_symbol: [u8; 8], witness cliff_period: u64, witness total_period: u64,39// ... remaining source is available in the playground
$cellc metadata examples/token.cell --target-profile ckb

Why developers use it

CellScript is for teams that want CKB contract intent to stay readable while iteration stays fast enough to keep editing in flow.

State changes are explicit

Actions say which Cells are consumed, created, replaced, burned, or relocked, so reviewers can follow transaction shape.

Compiler checks catch drift

Type, lifecycle, policy, and target checks run before generated code reaches a builder, deployment process, or VM harness.

Build evidence is inspectable

The compiler emits metadata for actions, types, hashes, effects, and CKB warnings that tools and reviewers can read.

From .cell to CKB code

The homepage keeps the pipeline high level. Detailed language concepts, generated metadata, and registry policy belong in Docs and Registry flows.

Write .cell source

Define Cell data, locks, and allowed transaction actions.

Check the rules

Catch invalid fields, state changes, and Cell lifecycles early.

Record review facts

Write JSON for actions, types, hashes, and policy checks.

Generate CKB instructions

Turn the checked model into ckb-vm RISC-V code.

Write the artefact

Produce assembly or ELF plus matching metadata.

Try the contract shapes

The Playground opens real example sources and compiles them in the browser. Test the contract shape first, then move to local CKB target builds.

Try it locally

Use the local compiler when you want the fast path from source to CKB target output plus inspectable metadata.

1

Install

cargo install --path .

2

Compile

cellc examples/token.cell --target riscv64-elf --target-profile ckb

3

Check

cellc check --target-profile ckb