Todas as lições · CKB node, RPC and indexer · Começa aqui · Glossário
Finding cells of a ckb_js_vm JS contract needs a second indexer prefix searchPráticoDe uma correção
De uma correção · Verificação: certa · Verificada em 2026-11-19
A cell that runs a JS contract carries the ckb_js_vm script as its lock or type. Its args are 2 flag bytes, then the contract's 32 byte code hash, then its hash type byte (data 0, type 1, data1 2, data2 4). A get_cells prefix search on the contract's own code_hash finds none of these cells, so also run a prefix search on the ckb_js_vm script with args set to flags plus code hash plus hash type byte, and merge the results. With 0x0000 as the flags, that search only matches cells whose flags are zero.
Porque importa: Without the second search, an explorer or indexer query reports zero live cells for every JS contract, even when many exist.
Padrão
prefixes.push({ code_hash: vm.codeHash, hash_type: vm.hashType, args: "0x0000" + s.codeHash.slice(2) + Number(byte).toString(16).padStart(2, "0") });Tirado do commit, encurtado.
- Conceitos
- Indexer queries and cell collection, Data encoding (molecule, hex, bigints)
- Evidência
- De uma correção: de um projeto, verificada contra o commit
- Vista pela primeira vez
- 2026-10-25
- Última mudança
- 2026-10-25
- Última verificação
- 2026-11-19
- Verificação contra o commit
- certa: a lição sai do commit e continua a valer no código de hoje
Fontes (1)
- 2026-10-25 · wildanrhmn/ckb-devnet-explorer · mais deste projeto
Mais sobre CKB node, RPC and indexer
- Nervos DAO phase 1 withdrawing cells keep the DAO type; count deposits by 8 zero bytes of data
- Filter prefix get_cells results by data length before decoding
- Check chain-wide script users before consuming a deployed code cell
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
LusoCryptoLabs, "Finding cells of a ckb_js_vm JS contract needs a second indexer prefix search", CKB lessons, https://pulse.lusocryptolabs.com/learned/node/finding-cells-of-a-ckb-js-vm-js-contract-needs-a-second-inde, CC BY 4.0, last changed 2026-10-25.