CKB Pulse

All lessons · Apps and UI · Start here · Glossary

Occupied capacity depends on the actual lock's args lengthWorkingFrom one fix

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

When quoting the capacity for cells locked to a user's wallet, compute the occupied size from the connected lock script (8 capacity bytes + 32 code_hash + 1 hash_type + args length + type + data), not a hardcoded value. In this commit a JoyID lock with 22 byte args gives a 222 CKB claim cell and a secp256k1 lock with 20 byte args gives 220 CKB. The script's molecule serialization header does not count toward occupied capacity.

Why it matters: A hardcoded lock size misquotes the capacity for any wallet whose lock args differ in length. In this commit that is 2 CKB per claim cell between JoyID (22 bytes) and secp256k1 (20 bytes), so the quoted total the user agrees to would not match what the transaction needs.

Distinct from the pre-sign checker lesson: this is about sizing by the connected lock's real args length.

Pattern

Prefer
const lockScriptSize = (lockScript) => 32n + 1n + argsLength(lockScript);

Taken from the commit, shortened.

A test changed in the same commit

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

Concepts
Capacity and cell size
Evidence
From one fix: from one project, checked against its commit
First seen
2026-09-23
Last changed
2026-09-23
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 Apps and UI

All 9 in this topic

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

Cite this lesson
LusoCryptoLabs, "Occupied capacity depends on the actual lock's args length", CKB lessons, https://pulse.lusocryptolabs.com/learned/apps/occupied-capacity-depends-on-the-actual-lock-s-args-length, CC BY 4.0, last changed 2026-09-23.

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.