All lessons · CKB node, RPC and indexer · Start here · Glossary
Computing a transaction's molecule packed size from RPC JSONAdvancedFrom one fix
From one fix · Check: right · Checked 2026-11-19
A CKB Transaction's packed size (the length of get_transaction with verbosity 0) can be computed from its RPC JSON without serializing it. It is 12 (table header) + RawTransaction + witnesses. RawTransaction is 28 (table header) + 4 (version) + cell_deps (4 + 37 each) + header_deps (4 + 32 each) + inputs (4 + 44 each) + outputs + outputs_data. Each CellOutput is 16 + 8 + lock size, plus the type script size only when a type is present. Each Script is 53 + len(args). A dynvec costs 4 + 4 * count + the sum of its item sizes, and every Bytes item in outputs_data and witnesses costs 4 + len.
Why it matters: Without the exact molecule layout, a tool cannot confirm the node's reported packed transaction size from RPC JSON. The cross-check against the measured node wire bytes would then fail or be skipped.
Pattern
return 12 + raw_size + dynamic([4 + len(raw(v)) for v in tx['witnesses']])Taken from the commit, shortened.
- Concepts
- Data encoding (molecule, hex, bigints), Transaction building and fees
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-10-10
- Last changed
- 2026-10-10
- 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)
- 2026-10-10 · Tactus-Labs/tactus-o1 · more from this project
More about CKB node, RPC and indexer
- Decoding the packed epoch field (number, index, length)
- Nervos DAO compensation from the header's accumulated rate (AR)
- Nervos DAO phase 1 withdrawing cells keep the DAO type; count deposits by 8 zero bytes of data
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Computing a transaction's molecule packed size from RPC JSON", CKB lessons, https://pulse.lusocryptolabs.com/learned/node/computing-a-transaction-s-molecule-packed-size-from-rpc-json, CC BY 4.0, last changed 2026-10-10.