Start Your CKB Development Journey | Digest #4

Start Your CKB Development Journey | Digest #4

·

6 min read

In the past month, Cryptape and MIT Bitcoin Expo both hosted CKB hackathons that provided developers with an opportunity to explore the CKB blockchain platform. Attendees were able to learn about CKB's unique Cell Model and its capabilities for creating complex smart contracts. The hackathon allowed participants to showcase the platform's features and interoperability with other blockchain technologies through various challenges.

How to set up a basic development environment for CKB?

When it comes to setting up the basic development environment for CKB, developers have two options: setting up the development chain locally or using the testnet of public nodes directly. For early-stage development, building the development chain locally is the more recommended approach. This is because it allows for greater control over the interval between blocks and enables pre-allocation of funds without the need to wait for a faucet to collect them, as is necessary when using the testnet.

1. Public Nodes

2. Set up a development chain locally

  1. Download the Latest CKB Binary

    Download the latest CKB binary file from the CKB releases page on GitHub.

    Use the following commands to verify that the binaries are working and to check their versions:

     ckb --version
     ckb-cli --version
    
  2. Initialize the Configuration To initialize the development blockchain and generate the necessary configuration files, use the following command:

     # <TARGET> indicates a local directory
     ckb init --chain dev -C <TARGET>
    
     WARN: mining feature is disabled because of lacking the block assembler config options
     Initialized CKB directory in <TARGET>
     create specs/dev.toml
     create ckb.toml
     create ckb-miner.toml
     create default.db-options
     Genesis Hash: 0xfb4751c16b865d8b59bb6da46141abe8bb286a4b0e3cc1e52b4b1195884f4160
    
  3. Configure the Block Assembler

    The Block Assembler configuration specifies which address should be receive block rewards for mining.

    • Create a New Account

      An address to receive the block rewards must be created. We can do this using ckb-cli. Note: Be sure to record the lock_arg value in the response which we will use in the next step.

        address:
        mainnet: ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqg8hc4r5a54a92jj7tdmh0zvumwurazrecr6taxa
        testnet: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqg8hc4r5a54a92jj7tdmh0zvumwurazrecdgqjv9
        address(deprecated):
        mainnet: ckb1qyqq00328fmft62499ukmhw7yeekac86y8ns3kysl4
        testnet: ckt1qyqq00328fmft62499ukmhw7yeekac86y8nsvn60nf
        lock_arg: 0x07be2a3a7695e95529796dddde26736ee0fa21e7
        lock_hash: 0xcb52ab34a5348ebdd95e6da58573ea8e80369b89d9a6b6cf16505616c0a7c0e9
      
    • Update the <TARGET>/ckb.toml

        [block_assembler]
        code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" # Do not change this.
        args = "0x07be2a3a7695e95529796dddde26736ee0fa21e7" # Change this to your lock_arg value.
        hash_type = "type" # Do not change this.
        message = "0x" # Change this to "0x" to supply an empty message.
      
  4. Adjust the Parameters to Shorten the Block Interval

    For most development purposes, the default configuration should be sufficient. However, sometimes it is beneficial to speed up specific operations to quickly view results.

    • Change the Number of Blocks in an Epoch

      The default epoch length is 1000 blocks. Reducing this to 10 or 100 can help with testing Nervos DAO operations. Modify the genesis_epoch_length parameter in the <TARGET>/specs/dev.toml file under the params section:

        [params]
        genesis_epoch_length = 1000  # The unit of meansurement is "block".
      
    • Change the Mining Interval

      The default mining interval is 5000, which is a value in milliseconds, meaning 5 seconds. Reducing this value will create blocks faster. Modify the value parameter in the <TARGET>/ckb-miner.toml file under the miner.workers section:

        [[miner.workers]]
        worker_type = "Dummy"
        delay_type = "Constant"
        value = 5000 #milliseconds
      
  5. Start

    • Start the CKB Node

        ckb run -C <TARGET> --indexer
      
    • Start the CKB Miner

        ckb miner -C <TARGET>
      

Your Burning Questions Answered

  • What are the three different types of CKB nodes and what are their respective roles in the network?

    CKB nodes have three types:

    • Mining Nodes: They participate in the CKB Proof-of-Work consensus process. Mining nodes collect new transactions, package them into blocks and produce new blocks.

    • Full Nodes: They verify new blocks and transactions, relay blocks and transactions, and select the chains they consent to fork. They are the verifiers of the network.

    • Light Nodes: They trust full nodes. With minimal resources, they subscribe and store a subset of cells of their interests.

  • Where can you receive testnet CKB for development and testing purposes?

    The facucet: https://faucet.nervos.org/

Blockchain Highlights

Gridless is a project that brings affordable energy to rural communities in Africa using microgrids and Bitcoin mining. It aims to make microgrids financially sustainable and push for more electrification in Africa while promoting Bitcoin mining decentralization. CoinDesk named it as one of its Projects to Watch for 2023.

The rise of digital tools does not necessarily lead to fewer and less meaningful connections. Digital-first connections might actually be just what our physical lives have been missing. Existing ways of networking have mostly sucked, and digital tools are better at the parts of connecting that have always been the hardest. However, for digital-first networking to dramatically improve our lives, it has to get a lot better at facilitating connection and connection-strengthening. Areas worth exploring include group chats, open graphs, and tools for the digital-to-physical moment.

The author argues that Web3 and AI are compatible with each other, and that Web3's permissionlessly programmable nature allows AI to flourish. They believe that AI will dominate the edges of Web3 networks, where humans currently operate, and that this will enable novel consumer experiences in various applications such as social media and gaming. The interactions between AI agents and humans, as well as between AI agents themselves, will occur through smart contracts.

Network & Code

We are thrilled to announce the exciting projects that came out of our recent Hackathon! Participants created innovative and diverse applications that showcased the potential of the CKB blockchain platform. Check them out on the Project List!

💪 Let's keep building! Stay tuned for more updates and future events!

Top 3 Projects

1. CKBGPT

Project Description

A chatbot powered by ChatGPT and LangChain. Ask anything about https://github.com/nervosnetwork/ckb. eg: role of xx file/role of xx folder, weblink: https://ckbgpt.fly.dev

Link to project repository

https://github.com/tianlitao/toly-gpt

Team Information

A team called CKBGPT was created by tianlitao.

Team Mentor: Yukun

2. CKB Academy

Project Description

CKB Academy is committed to ensuring that new CKB developers have an easy learning curve, by providing easy-to-understand, interactive courses and friendly documentation. Our mission is to foster a robust ecosystem around Nervos Network by providing developers with all the tools and resources they need to create innovative applications and solutions.

Link to project repository

https://github.com/Flouse/ckb-academy

Team Information

A team consisting of Jason Huang.

Team Mentor: Flouse

Project Description

Create a customized search engine and Telegram Bot accompaniment to streamline access to information. The search engine is a customized Google engine indexing a list of known resources. New resources can easily be suggested and implemented. Accompanying Telegram Bot contains several commands from its '/' menu which provide links to useful data on GitHub using the GitHub REST API, which will update with the repositories. Bot contains RFCs lookup and system/production/miscellaneous script repositories indexing and linking, as well as a general References lookup containing other handpicked repositories. The search engine is on a free hosted website https://nervosdocs.weebly.com/. The Telegram Bot's handle is @NervosDocBot. All its commands are in line with the user and will always post its responses in private messages rather than in channel. It runs on an ESP32 micro controller, which allows it to queue and process requests individually.

Link to project repository

https://github.com/toastmanAu/Nervos-Doc-Search-Bot

Team Information

A team called Toastman was created by Phill.

Team Mentor: Drift Luo