Spore Examples
Here we provide several examples which are minimum viable snippets designed for a Node environment, each showcasing a specific feature implemented using the Spore SDK.
These examples serve as practical guides for developers, demonstrating how to implement specific features in a straightforward manner, for instance, how to create a spore by a transaction with spore-sdk. And for those who are looking for documentation on how to develop a fully functional application, refer to: Spore Demos.
Scenario examples
Creating your first spore on-chain
Spore-first-example is a hello world example for spore-sdk, showing you how to upload an image file and create a spore on Nervos CKB in a split second. This is a well-suited code example for beginners to learn the very basics of Spore Protocol.
Lock script examples
CKB default lock
CKB default lock is the most commonly used lock script on Nervos CKB, also a great starting point for beginners due to its simplicity. Let's check out some examples using the CKB Default lock:
- Create Spore - Create a spore with CKBytes
- Transfer Spore - Transfer the ownership of a spore from A to B
- Melt Spore - Melt a spore and redeem occupied CKBytes
- Create Cluster - Create a cluster with CKBytes
- Transfer Cluster - Transfer the ownership of a cluster from A to B
Anyone-can-pay
Anyone-can-pay (ACP) lock can be unlocked by anyone without signature verification and accepts any amount of CKB/UDT payment for using the cluster. Check out these code examples:
- Create Public Cluster - Create a cluster that can be used by anyone with or without a fee
- Create Spore with Public Cluster - Create a spore using CKB default lock associated with an Anyone-can-pay lock cluster
Omnilock
Omnilock is a universal and interoperable lock script supporting various blockchains (Bitcoin, Ethereum, EOS, etc.) verification methods and extensible for future additions. Combine Omnilock with spore-sdk to:
- Create Public Cluster - Create a cluster that accepts payment per usage by anyone
- Create Omnilock Spore with Public Cluster - Create an spore using Omnilock associated with an Omnilock-ACP lock cluster