CCC uses a declarative transaction model: you describe what you want the transaction to do, then call helpers to fill in the rest automatically — collecting inputs, calculating fees, and broadcasting.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ckb-devrel/ccc/llms.txt
Use this file to discover all available pages before exploring further.
Core concepts
On CKB, every output must declare its capacity in shannon (1 CKB = 10⁸ shannon). Useccc.fixedPointFrom(amount) to convert a human-readable CKB amount to the internal representation:
Transfer CKB
The following example (frompackages/examples/src/transfer.ts) sends exactly 100 CKB to a receiver address:
Describe the outputs
Create a transaction skeleton with just the outputs you want. CCC will figure out which inputs are needed.
Fill inputs by capacity
completeInputsByCapacity queries live cells owned by the signer and adds them as inputs until the total capacity covers all outputs.Pay the fee
completeFeeBy adds a change output back to the signer and adjusts its capacity to cover the network fee. The fee rate is calculated automatically based on current network conditions.Transfer all CKB
To sweep all CKB from an account — for example when emptying a wallet — usecompleteInputsAll combined with completeFeeChangeToOutput. This example is from packages/examples/src/transferAll.ts:
completeFeeChangeToOutput(signer, 0) adjusts the capacity of the output at index 0 downward to pay the fee. Make sure that output exists before calling this method.Fee calculation
You never need to set fee rates manually. CCC fetches the current median fee rate from the node and uses it automatically when you callcompleteFeeBy or completeFeeChangeToOutput.
If you need fine-grained control you can pass an explicit fee rate (in shannon per kilobyte) as the second argument:
API reference
| Method | Description |
|---|---|
ccc.Transaction.from(skeleton) | Create a transaction from a partial description |
ccc.fixedPointFrom(amount) | Convert CKB amount to shannon (bigint) |
tx.completeInputsByCapacity(signer) | Add inputs until capacity is sufficient |
tx.completeInputsAll(signer) | Collect all cells owned by the signer |
tx.completeFeeBy(signer, feeRate?) | Add change output and pay fee |
tx.completeFeeChangeToOutput(signer, index, feeRate?) | Deduct fee from a specific output |
signer.sendTransaction(tx) | Sign and broadcast; returns tx hash |