Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ckb-devrel/ccc/llms.txt
Use this file to discover all available pages before exploring further.
New to CKB? Read the Nervos CKB Docs for
foundational knowledge.
What is the cell model?
CKB uses a generalized UTXO model called the cell model. Like Bitcoin UTXOs, cells are discrete units of state that are consumed by transactions and replaced with new cells. Unlike Bitcoin UTXOs, each cell can store arbitrary data and be governed by programmable scripts. Every cell has four fields:| Field | Type | Description |
|---|---|---|
capacity | Num | Storage space in Shannon (1 CKB = 100,000,000 Shannon) |
lock | Script | Defines ownership — who can consume this cell |
type | Script | undefined | Defines asset behavior — optional type constraints |
outputData | Hex | Arbitrary bytes stored in the cell |
CellOutput class represents the structured output portion of a cell:
Cell class:
Scripts
Scripts are the programmable logic attached to cells. CKB executes scripts in a RISC-V virtual machine to validate transactions.Script from a plain object:
Lock scripts
A lock script defines ownership of a cell. A transaction can only consume a cell if the lock script’s conditions are satisfied — typically by providing a valid cryptographic signature. The most common lock on CKB isSecp256k1Blake160, which works similarly to Bitcoin’s P2PKH.
Type scripts
A type script constrains how a cell can be transformed. It runs on both the consumed inputs and the created outputs, making it suitable for enforcing asset rules — for example, ensuring a UDT (User-Defined Token) supply is not inflated when tokens are transferred. Type scripts are optional. A cell without a type script has no asset-level constraints beyond its lock.Capacity and Shannon
Capacity is measured in Shannon — the smallest unit of CKB:ccc.fixedPointFrom() to convert human-readable CKB amounts to Shannon:
fixedPointFrom function has a default decimal precision of 8, matching CKB’s Shannon denominator.
OutPoint
AnOutPoint uniquely identifies a specific cell on the chain by referencing the transaction that created it and its position within that transaction’s outputs:
OutPoint through a CellInput:
Addresses
A CKB address is an encoding of a lock script. Addresses are derived from the script’scodeHash, hashType, and args, combined with a network prefix (ckb for mainnet, ckt for testnet).
signer.getRecommendedAddress(), CCC encodes the signer’s lock script into the appropriate address format for the connected network.
How CCC abstracts the cell model
CCC provides TypeScript classes and methods that manage the low-level details of the cell model:Transaction.from()— constructs a transaction from a plain object, automatically calculating capacities where omittedcompleteInputsByCapacity(signer)— finds and adds input cells from the signer’s address to cover required capacitycompleteFeeBy(signer)— calculates the transaction fee and adds a change outputScript.fromKnownScript(client, KnownScript.Secp256k1Blake160, args)— looks up well-known script code hashes by name
OutPoint or Script objects by hand. CCC’s helper methods handle encoding, hashing, and on-chain lookups for you.