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
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.
- toastmanAu/openswap:
pool-sdk/test/builders.test.ts,pool-sdk/test/cli.test.ts,pool-sdk/test/codec.test.ts,pool-sdk/test/transport.test.ts,pool-sdk/test/vm-bridge.ts
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)
- 2026-10-01 · toastmanAu/openswap · more from this project
More about CCC (TypeScript SDK)
- completeFeeBy adds change instead of shrinking outputs, breaking output bound proofs
- Parsing snake_case JSON-RPC transactions in CCC
- Reserve co-signer witness space before completeFeeBy in multi-signer CCC transactions
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.