CKB Pulse
Lessons

What CKB learned

Start here · Glossary · Test yourself · Feed

“Cell deps and script lookup”

31 lessons found. All lessons

Page 1 of 3

Resolving cell deps per cell after redeploying a data-hashed scriptWorkingFrom one fix

After a data/data1 type script is redeployed with a new code hash, old cells still run against the old code. Keep a list of retired deployments and query the indexer for every one. Pick each cell's cell dep by matching the codeHash and hashType of that cell's own type script, not a single 'current' manifest entry.

#Cell deps and script lookup #Type ID and upgrades #Indexer queries and cell collection · Sources (1) · 2026-11-17

Verifying an immutable data1 script code cell after deploymentWorkingFrom one fix

For a script referenced by hashType 'data1', put the binary in a cell whose lock is the always fail lock (codeHash 32 zero bytes, hashType data1, args 0x, which no code cell can match) and with no type, so the cell can never be spent and the cell dep stays live; the capacity is locked forever. After sending, read the cell with client.getCellLive(outPoint, true) and assert that ccc.hashCkb(outputData) equals the pinned code hash, that the lock equals the always fail lock and that there is no type, ideally on more than one endpoint. The data1 code hash is already pinned by the binary's content; the immutable lock is what keeps the cell available.

#Cell deps and script lookup #Type ID and upgrades · Sources (1) · 2026-10-29

Check chain-wide script users before consuming a deployed code cellWorkingChecked by the owner

Before consuming a deployed code cell, call indexer get_cells across the whole chain with script_search_mode "prefix" and args "0x", once as lock and once as type. Query the cell's data hash with hash_type data, data1 and data2, and for a Type ID cell also its type script hash with hash_type type. Zero results only means no live cell uses the binary right now. Consuming the cell is irreversible, and a Type ID identity cannot be recreated, so treat unused Type ID cells with extra caution.

#Cell deps and script lookup #Indexer queries and cell collection #Type ID and upgrades · Sources (2) · 2026-10-10

Output type scripts need cell deps too, including the native DAO typeBasicFrom one fix

CKB runs the type script of every output (not only input locks and input types), so a transaction that creates a native DAO deposit must include the DAO type's code cell (genesis tx0 index 2) as a cell dep, or the node rejects it with ScriptNotFound on Outputs[i].Type. Pre-send checks that only verify deps for input locks will miss this; check every input lock, input type and output type, deduplicated by code_hash and hash_type.

#Cell deps and script lookup #Transaction building and fees · Sources (1) · 2026-10-05

Delegating script validation via exec to a hash bound cell depWorkingFrom one fix

This lifecycle type script stores a 32 byte data hash in its args, scans cell deps with load_cell_data_hash to find exactly one match (rejecting duplicates), then calls ckb_std syscalls::exec on that dep, which keeps the current Script context (GroupInput, GroupOutput, args) for the child. Because exec only returns when it fails, any code after the call must return an error instead of falling through to success.

#Cell deps and script lookup #Type ID and upgrades · Sources (1) · 2026-10-04

Derive devnet Spore and system script cell deps from a fresh OffCKB exportWorkingSeen again

Do not hardcode devnet code hashes and cell dep out points (secp256k1, Spore, cluster) in an example: they come from the local OffCKB devnet and can drift when OffCKB's bundled scripts change. Export them with `offckb system-scripts --network devnet --export-style ccc` before start, fail if a needed script lacks codeHash, hashType or a cellDep outPoint, and build both the CCC client config and the Spore SDK lumos config from that one file.

#Cell deps and script lookup #Testing and devnet · Sources (2) · 2026-09-29

Verify a deployed code cell is canonical and live before recording it as a cell depWorkingFrom one fix

Before writing a deployment manifest for a code cell, this commit checks get_transaction is committed, that get_block_hash at the header number equals the block hash (not reorganized), and that get_live_cell still reports status live with the expected data hash. It then repeats the canonical and live checks after all reads (on two independent RPCs), so a stale, spent or reorganized cell never yields a manifest.

#Cell deps and script lookup #Network and RPC reliability · Sources (1) · 2026-11-09

Saved transaction test vectors go stale when their cell deps are spentWorkingChecked by the owner

A saved CKB transaction lists its cell deps by out point. A replay that resolves those deps as live cells, as a node does when it verifies a new transaction, stops working once a lock upgrade or redeployment spends a dep cell, although neither the saved transaction nor the verifier changed. A replay test should tell that case (a dep that is no longer live) apart from a real verification failure, and skip the vector with a note instead of reporting a defect.

#Testing and devnet #Cell deps and script lookup · Sources (1) · 2026-11-09

JoyID sub key signatures depend on the live CoTA cell dep holding the sub key rootAdvancedChecked by the owner

A JoyID sub key (second device) signature is checked by the JoyID lock against the sub key root held in the account's CoTA cell, which the transaction carries as a cell dep. Adding a device spends that CoTA cell and creates a new one with a new root. Two separate things follow: a transaction that still lists the old CoTA out point has a cell dep that is no longer live, and the lock run against the old root data does not accept the sub key signature.

JoyID specific: sub key root lives in the CoTA cell dep.

#Cell deps and script lookup #Witnesses and signatures · Sources (1) · 2026-11-06

Binding an off-chain lock proof to the live cell deps it ran withAdvancedChecked by the owner

When an off-chain signature proof is verified by running the lock against cell deps read live from the chain, record every out point those deps resolved to, dep group members included. Treat the resulting authorization as valid only while all of those cells are still live. A lock upgrade, a redeployment, or a key rotation or recovery in a lock that keeps its keys in a dep cell spends one of them, and the owner must prove again.

#Cell deps and script lookup #Login and authorization · Sources (1) · 2026-11-04

Carry type script and data into the output when spending a lock-only custody cellWorkingFrom one fix

When a custom lock's spend rebuilds an output from an input cell that may carry a type script (a UDT held in custody, say), copy cell.cellOutput.type and cell.outputData into the output and change only the lock; writing outputsData "0x" with no type burns or strands the token. Add the type script's cell deps to the transaction before signing, because the signature covers the cell deps and callers cannot append them afterwards, and refuse to build the spend if a typed cell comes without them. If the lock also constrains who gets the capacity (as Tranfr's recipient claim does today), follow that rule instead of a plain copy.

#Transaction building and fees #Cell deps and script lookup #Witnesses and signatures · Sources (1) · 2026-10-21

Recognising a Nervos DAO deposit cell referenced as a stake cell depWorkingFrom one fix

A Nervos DAO deposit cell has the DAO type script (code hash 0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e, hash_type type, empty args) and 8 zero bytes of data; a withdrawing cell has the same type script but the deposit block number as data. A contract that accepts one as a cell dep must check code hash, hash_type, empty args and data == 8 zero bytes, since the DAO script does not run for a dep. For the same reason a ckb_testtool test can create such cells directly with the DAO type script and zero data, without deploying the DAO binary.

#Cell deps and script lookup #Testing and devnet · Sources (1) · 2026-10-20

Page 1 of 3

Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. JSON · Want a lesson changed or removed? Open an issue.