CKB Pulse

All lessons · Other · Start here · Glossary

Hand-encoding WitnessArgs in moleculeWorkingFrom one fix

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

WitnessArgs is a molecule table of three BytesOpt fields (lock, input_type, output_type). An absent field takes zero bytes, but a present empty field still takes a 4-byte length header, so the two encode differently. The table starts with a u32le total size, then three u32le offsets, the first being 16 (4 + 4*3), each counted from the start of the table. Check any hand-written encoder byte for byte against ccc.WitnessArgs.from(...).toBytes(), including the cases lock only, all absent, and a present empty field.

Why it matters: A hand-written encoder that treats an empty field like an absent one, or gets the offsets wrong, produces witness bytes that do not match what CCC and the scripts expect.

A test changed in the same commit

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

Concepts
Data encoding (molecule, hex, bigints), Witnesses and signatures
Evidence
From one fix: from one project, checked against its commit
First seen
2026-11-14
Last changed
2026-11-14
Last checked
2026-11-19
Check against the commit
partly right: a true core, with a part that is loose or too wide

Sources (1)

More about Other

All 9 in this topic

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

Cite this lesson
LusoCryptoLabs, "Hand-encoding WitnessArgs in molecule", CKB lessons, https://pulse.lusocryptolabs.com/learned/other/hand-encoding-witnessargs-in-molecule, CC BY 4.0, last changed 2026-11-14.

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.