LiçõesO que a CKB aprendeu
Começa aqui · Glossário · Testa-te · Feed
As lições estão escritas em inglês, por isso pesquise em inglês.
#Cell deps and script lookup ✕
31 lições encontradas. Todas as lições
AnteriorPágina 2 de 3Seguinte
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 · Fontes (1) · 2026-11-04
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 · Fontes (1) · 2026-10-29
OffCKB 0.4.13's system scripts export for the devnet Spore V2 deployment has only codeHash, hashType and cellDeps, with no field for the protocol mode. When building a SporeScriptInfoLike from it for @ckb-ccc/spore createSpore({ scriptInfo }), set cobuild: true yourself, because the deployed binary uses cobuild semantics. Treat that flag as an assumption you pin, not something read from the export.
cobuild: true needed for OffCKB devnet Spore scripts.
#Cell deps and script lookup #Testing and devnet · Fontes (1) · 2026-10-28
On a devnet, if you construct a CCC client with a custom `scripts` map that overrides only `KnownScript.Secp256k1Blake160`, `SignerCkbPrivateKey` can still fail. This commit's comment says the signer also loads AnyoneCanPay metadata while classifying related locks, so it adds a `KnownScript.AnyoneCanPay` entry to the map even though no ACP input or cell dep is used.
#Cell deps and script lookup #Testing and devnet · Fontes (1) · 2026-10-23
When a lock spawns a verifier script from a cell dep with ckb-std 1.1.0 syscalls::spawn, it creates a pipe and passes the read fd in SpawnArgs.inherited_fds as an array ending in 0. After writing the full request, the parent closes write_fd so the child's read returns 0 or OtherEndClosed (end of input), then uses syscalls::wait(pid) == 0 as the verification result.
#Cell deps and script lookup #Other · Fontes (1) · 2026-10-22
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 · Fontes (1) · 2026-10-21
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 · Fontes (1) · 2026-10-20
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 · Fontes (2) · 2026-10-10
To check that a Script points at a given deployed code Cell, compare its code_hash with ckb blake2b256 of the Cell's output data when hash_type is data, data1 or data2 (0, 2, 4), and with the hash of that Cell's Type Script when hash_type is type (1). A type selection needs the code Cell to actually carry a Type Script, and other hash_type values are rejected.
#Cell deps and script lookup #Data encoding (molecule, hex, bigints) · Fontes (2) · 2026-10-09
CKB picks the VM version from the Script hash_type: data (0) runs VM0, data1 (2) runs VM1, data2 (4) runs VM2, and type (1) runs the latest activated VM. Code deployed for VM2 and pinned by data hash must be referenced with hash_type data2. The same code hash with data or data1 still resolves to the same cell but runs under an older VM, so tooling should reject those hash types for a VM2 target rather than only checking that the code hash matches.
#Cell deps and script lookup #Type ID and upgrades · Fontes (1) · 2026-10-09
In a ckb-std script you can load a cell's type script into a fixed 49 byte buffer with syscalls::load_cell_by_field(..., CellField::Type), then compare code_hash at bytes 16..48 and hash_type at byte 48 of the molecule Script table, without allocating for args. A short buffer returns Err(SysError::LengthNotEnough) yet still fills the buffer, so treat that error like Ok, and treat ItemMissing as a cell with no type script.
#Data encoding (molecule, hex, bigints) #Cell deps and script lookup · Fontes (1) · 2026-10-07
When a script reads the raw transaction's cell_deps (via load_transaction) and uses a position there as a Source::CellDep index for load_cell_type_hash or load_cell_data, the mapping holds only for the leading run of dep_type code entries, because dep groups expand into their member cells and shift later indexes. This vote script restricts its proposal and deposit lookups to that direct prefix and lets wallet dep groups follow it.
#Cell deps and script lookup · Fontes (1) · 2026-10-07
AnteriorPágina 2 de 3Seguinte
Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. JSON · Queres que uma lição seja mudada ou retirada? Abre um issue.