CKB Pulse

Todas as lições · Rust scripts and ckb-std · Começa aqui · Glossário

Molecule hash_type byte valuesPráticoDe uma correção

De uma correção · Verificação: certa · Verificada em 2026-11-19

In the molecule Script encoding, hash_type is data=0, type=1, data1=2, data2=4; 3 is not a valid value. Using 2 where you meant data2 builds a valid data1 script with a different hash, so indexer queries on it return nothing. Assert the raw byte inside the encoded Script, or run against a real devnet, because mocks that reuse the same constant on both sides cannot catch it.

Porque importa: With data2 encoded as 2, the service built a data1 script that matched no cell, so its Node Cell query found nothing and every run reported dropped; the mock chain used the same constant on both sides and never caught it.

Padrão

const HASH_TYPE_DATA2: u8 = 2; // wrong, 2 is data1; correct value is 4
Conceitos
Data encoding (molecule, hex, bigints), Indexer queries and cell collection, Testing and devnet
Evidência
De uma correção: de um projeto, verificada contra o commit
Vista pela primeira vez
2026-11-15
Última mudança
2026-11-15
Ú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)

Mais sobre Rust scripts and ckb-std

Ver as 35 deste tema

Manténs um projeto de onde esta lição veio? Confirma ou corrige

Citar esta lição
LusoCryptoLabs, "Molecule hash_type byte values", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/molecule-hash-type-byte-values, CC BY 4.0, last changed 2026-11-15.

Tiradas de commits públicos e verificadas contra o commit de onde cada uma veio e o código de hoje do projeto. Lê a fonte antes de confiar numa. Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. Queres que uma lição seja mudada ou retirada? Abre um issue.