CKB Pulse

All lessons · CCC (TypeScript SDK) · Start here · Glossary

Deriving minimum cell capacity with ccc.CellOutput.from and output dataWorkingReproduced

Reproduced · Check: right · Checked 2026-11-19

In CCC, calling ccc.CellOutput.from({lock, type}, outputData) without a capacity fills capacity with the cell's occupied size, so it serves as the minimum capacity check for change or receipt cells. This commit uses it to reject dust change before and after subtracting the fee (via transaction.estimateFee), and to top up a receipt cell whose received CKB is below its occupied capacity.

Why it matters: Without deriving occupied capacity, change or receipt outputs can fall below the cell's minimum capacity (for example after the fee is subtracted, or when a small CKB amount is received), producing a transaction the node rejects for insufficient output capacity.

Pattern

Prefer
return ccc.CellOutput.from({lock:cell.cellOutput.lock,type:cell.cellOutput.type},cell.outputData).capacity;

Taken from the commit, shortened.

A test changed in the same commit

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

Reproduced by a test

A public test runs what this lesson says on @ckb-ccc/core 1.23.1, with no node. Anyone can run it.

tests/ccc/minimum-capacity.test.mjs

Concepts
Capacity and cell size, Transaction building and fees
Evidence
Reproduced: reproduced by a public test
First seen
2026-10-01
Last changed
2026-10-01
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 CCC (TypeScript SDK)

All 33 in this topic

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

Cite this lesson
LusoCryptoLabs, "Deriving minimum cell capacity with ccc.CellOutput.from and output data", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/deriving-minimum-cell-capacity-with-ccc-celloutput-from-and, CC BY 4.0, last changed 2026-10-01.

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.