CKB supports User Defined Tokens (UDT) — fungible tokens that live in theDocumentation 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.
data field of cells. The @ckb-ccc/ccc package includes first-class UDT support via the ccc.udt namespace.
xUDT vs basic UDT
| Basic sUDT | xUDT | |
|---|---|---|
| Standard | CKB RFC 25 | CKB RFC 52 |
| Extension support | No | Yes (owner-mode, RCE rules) |
KnownScript value | — (not in CCC) | ccc.KnownScript.XUdt |
| Production use | Legacy | Recommended |
Udt class in CCC supports both. By default it uses the SSRI execution model (on-chain script execution), and falls back gracefully to off-chain construction for legacy xUDT tokens.
Installation
Import
Udt class is available as ccc.udt.Udt.
Construct a Udt instance
A Udt instance is defined by two pieces of information:
code— theOutPointof the cell that holds the UDT script codescript— the type script that identifies this specific token
Transfer tokens
This example is frompackages/examples/src/transferUdt.ts. It sends 1 token unit to the signer’s own address:
Build the initial transfer output
udt.transfer creates a transaction with the output cells you want. It does not yet balance inputs.Fill UDT inputs
udt.completeBy collects the signer’s UDT cells until there is enough token balance to cover the outputs. Any surplus is sent back as a change cell.Fill capacity inputs
After UDT inputs are set, fill capacity inputs for the CKB needed to hold the cells.
Mint tokens
Minting works identically totransfer — it just creates new token outputs without requiring existing UDT inputs. The UDT script must grant the signer mint authority (typically through owner-mode in xUDT):
Read token metadata (SSRI tokens)
For SSRI-compliant UDTs, theUdt class can fetch on-chain metadata:
These methods return
undefined for legacy sUDT/xUDT tokens that do not implement the SSRI UDT interface. Check the return value before using it.API reference
| Method | Description |
|---|---|
new ccc.udt.Udt(code, script) | Construct a UDT instance |
udt.transfer(signer, transfers, tx?) | Build transfer outputs |
udt.mint(signer, mints, tx?) | Build mint outputs |
udt.completeBy(tx, signer) | Fill UDT inputs and add change |
udt.completeChangeToLock(tx, signer, lock) | Fill UDT inputs with a specific change lock |
udt.name() | Token name (SSRI only) |
udt.symbol() | Token symbol (SSRI only) |
udt.decimals() | Token decimals (SSRI only) |
udt.icon() | Token icon URI (SSRI only) |