Installation
- npm
- yarn
- pnpm
Import
ccc namespace and adds Spore-specific functions.
Create a Spore
UsecreateSpore() to mint a new NFT. Pass a SporeDataView that describes the content type and raw content bytes.
createSpore() returns:
tx— a transaction skeleton with the Spore output and required cell deps. You must callcompleteInputsByCapacity(signer)andcompleteFeeBy(signer)before broadcasting.id— the unique spore ID (a hex string) that identifies this NFT permanently on-chain.
SporeDataView fields
createSpore parameters
Cluster modes
When a Spore includes aclusterId, CCC must prove that the signer has permission to add a Spore to the cluster. The clusterMode parameter controls how this is done.
lockProxy (recommended)
lockProxy (recommended)
Adds a cell that shares the same lock as the cluster cell to both inputs and outputs. Suitable for public clusters where membership is proved by controlling the right lock script.
clusterCell
clusterCell
Puts the cluster cell itself into the transaction inputs and outputs. Use this for private clusters where you own the cluster cell directly.
skip
skip
Does not add any cluster-related inputs or outputs. Use only when you have already handled the cluster logic manually, or for testing.
Transfer a Spore
CalltransferSpore() to change the owner of a Spore. The transaction moves the Spore cell from the current owner’s lock to the recipient’s lock.
transferSpore parameters
Melt a Spore
Melting destroys a Spore permanently and releases the CKB capacity locked inside back to the signer’s address.Query Spores
Find Spores owned by the signer
findSporesBySigner() is an async generator that yields all Spores controlled by the connected wallet. Optionally filter by cluster ID.
Find Spores by lock or cluster
findSpores() searches by lock script and optional cluster ID. Use it when you want to query spores for an arbitrary address rather than the connected signer.
findSpores parameters
Complete example
create-and-send-spore.ts
Next steps
UDT Tokens
Work with fungible tokens on CKB using the UDT package.
Send CKB
Review the core transaction building primitives CCC uses under the hood.