CKB Pulse

All lessons · Rust scripts and ckb-std · Start here · Glossary

Type Script group membership and group witness index derived from the full script hashWorkingFrom one fix

From one fix · Check: right · Checked 2026-11-19

When locating a Type Script group off chain, match input and output cells by the blake2b hash of the complete Script (code_hash, hash_type, args), never by code hash alone. By convention (RFC 22 for lock groups), a group's witness sits at the transaction index of its first input, or of its first output if the group has no inputs. CKB does not enforce this: the script picks which witness it reads, and which WitnessArgs field (input_type or output_type) holds the data is the protocol's own choice.

Why it matters: If cells are matched by code hash alone, cells whose Type Scripts differ only in args or hash_type land in the group, so the off chain tool computes the wrong group members, cardinality and witness index compared with what the CKB VM executes.

Pattern

Prefer
output.type_script.as_ref().is_some_and(|script| hash(script.bytes) == selected_hash)

Taken from the commit, shortened.

A test changed in the same commit

It sits next to the fix. We did not run it.

Concepts
Witnesses and signatures, Transaction building and fees
Evidence
From one fix: from one project, checked against its commit
First seen
2026-10-09
Last changed
2026-10-09
Last checked
2026-11-19
Check against the commit
right: the lesson follows from its commit and still holds in the code today

Sources (1)

More about Rust scripts and ckb-std

All 35 in this topic

Do you maintain a project this lesson came from? Confirm or correct it

Cite this lesson
LusoCryptoLabs, "Type Script group membership and group witness index derived from the full script hash", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/type-script-group-membership-and-group-witness-index-derived, CC BY 4.0, last changed 2026-10-09.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.