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.
- toastmanAu/daowow:
apps/web/test/claim-codec.test.js
- 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)
- 2026-11-14 · toastmanAu/daowow · more from this project
More about Other
- Recognizing a Nervos DAO deposit cell (not a withdrawing one)
- Nervos DAO phase-two withdrawal since and amount
- Restrict script hashType to data, type, data1, data2 when loading config
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.