Nervos CKB Documentation

website·Indexed 36 days ago

https://docs.nervos.org

Official documentation for Nervos CKB, a proof-of-work layer 1 blockchain built around the Cell Model and CKB-VM. Includes guides on the Spore Protocol, xUDT (Extensible User-Defined Token) standard, native quantum resistance using SPHINCS+, and AI-assisted script development.

Tokens
115K
Snippets
478
Records
850
Agent score
69%

What's inside Nervos CKB

  1. Overview of the Anyone-Can-Pay Lock Script

    The Anyone-Can-Pay Lock Script allows users to send any amount of CKB or sUDT to a Cell without meeting the traditional minimum 61 CKBytes requirement. This is primarily used for small-value token transfers and micro-transactions. It supports two unlocking modes:

    1. Signature-Based Unlocking: If a valid signature matching the lock's public key hash is provided, the owner can spend the Cell normally.
    2. Non-Signature Unlocking (Anyone Can Pay): Allows anyone to add CKB or UDT to the cell without a signature, provided strict validation rules are met: only one input and one output Cell per unique Lock + Type Script pair, the output value must not be less than the input, and optional minimum thresholds must be satisfied.
  2. Overview of Programming on Nervos

    Nervos supports smart contract development using general-purpose programming languages including Rust, JavaScript, and C. All programs are executed within the CKB-VM, a high-performance RISC-V virtual machine designed for security and flexibility. The architecture supports massive parallelization by executing multiple instances of CKB-VM concurrently, allowing for significant scaling improvements. Programs can store data and state on-chain to facilitate the creation of complex applications and customized tokens.
  3. Overview of Spore Protocol for Digital Objects (DOB)

    Spore is an on-chain Digital Object (DOB) protocol built on Nervos CKB. It allows for the secure and flexible creation and transfer of digital assets (such as NFTs, gaming assets, and digital vouchers) directly on-chain. Unlike account-based models, Spore utilizes the CKB UTXO-based Cell Model, where each DOB typically occupies one Cell. Key features include on-chain content storage (up to 500KB), immutability, and the ability to redeem the asset's intrinsic value.
  4. Overview of Common Chain Connector (CCC) SDK

    The Common Chain Connector (CCC) is a JavaScript/TypeScript SDK specifically designed for CKB development. It is recommended as the primary development tool for CKB, providing an alternative to other libraries like Lumos and ckb-js-sdk. In addition to its SDK capabilities, CCC functions as a wallet connector to improve interoperability between wallets across different blockchains.
  5. Overview of secp256k1_blake160_multisig_all Lock Script

    The secp256k1_blake160_multisig_all is a CKB genesis Lock Script that allows a group of users to collectively sign a single transaction. It supports multiple signature verification and time-lock functionalities for Cells. To keep the on-chain Script size fixed regardless of the number of participants, it uses a scheme similar to Bitcoin's P2SH, where the args field contains the blake160 hash of the multisig_script rather than the script itself.
  6. Overview of ckb-cli features

    ckb-cli is a Rust-developed command-line tool used to interact with the CKB Mainnet blockchain. It provides capabilities for managing accounts, deploying Scripts, and sending Transactions. Key functional areas include:

    • rpc: Invoke RPC calls to a node
    • account: Account management
    • mock-tx: Verify and send mock transactions
    • tx: Handle common sighash and multisig transactions
    • util: General utilities
    • molecule: Encode and decode Molecule data
    • wallet: Transfer funds, query balances (via local index), and key utilities
    • dao: Deposit, prepare, withdraw, and query NervosDAO balances (via local index)
  7. Overview of Spawn for direct cross-script calls

    Spawn is a set of syscalls introduced in the Meepo hard fork (2024) that allows a CKB Script to create new processes for direct cross-script calls. Unlike the exec syscall, which discards the current script's state and context, spawn preserves the parent script's context. This allows the parent script to trigger a child script, wait for its execution result, and then continue its own execution.
  8. Overview of the Nervos CKB Cell Model

    Nervos CKB utilizes a generalized UTXO (Unspent Transaction Output) model known as the Cell Model for state storage. In this architecture, all system states are stored within 'Cells'. Computation is performed off-chain, while network nodes are responsible for the verification of these computations.
  9. Introduction to Fuzz Testing for CKB Scripts

    Fuzz testing is an automated software testing technique used in CKB script development to uncover edge cases that human-designed unit, integration, or property tests might miss. It involves providing invalid, unexpected, or random data as inputs to a program and monitoring for exceptions such as crashes, failed assertions, or memory leaks.

    In the context of CKB scripts, fuzzing is particularly useful for validating the parsing and handling of witness data. Since malicious data could be included in a witness to exploit a script, fuzzing helps ensure the script successfully detects and handles all invalid inputs by continuously generating or mutating data to explore new code paths.

    Key characteristics of modern fuzzing include:

    • Code Coverage Tracking: Fuzzers prioritize input data that activates new code paths to explore the program more efficiently.
    • Evolutionary Algorithms: Used to balance datasets that activate different code paths.
    • Corpus-Based Testing: Fuzzing typically starts with a 'corpus' (a set of seed data) which the fuzzer then mutates to generate new test cases.
    • Long-term Execution: Unlike unit tests, fuzzing is often a continuous process that may run for days or months to uncover rare edge cases.
  10. Overview of CKB-VM in Nervos

    CKB-VM is the virtual machine used by the Nervos blockchain. It is powered by the RISC-V instruction set and provides Turing-complete programmability, allowing for flexible and powerful smart contract execution within a secure, high-performance environment.
  11. Overview of CKB Crypto Service

    The ckb-crypto-service is a secure encryption service built on CKB's multi-process architecture and IPC (inter-process communication) mechanism. It decouples cryptographic logic from smart contracts to avoid compatibility issues and dependency conflicts. It supports Rust, C, and JavaScript and is the preferred infrastructure for implementing cryptographic functionality in CKB smart contracts.

    Supported algorithms include:

    • Blake2b
    • SHA-256 (SHA-2)
    • RIPEMD-160
    • Secp256k1
    • Schnorr
    • Ed25519
  12. Overview of CCC SOL Lock for Solana Wallet Interoperability

    The CCC (Common Chains Connector) SOL Lock is a framework that enables interoperability between Solana wallets and Nervos CKB. It allows CKB transactions to be signed with Solana wallets using the Ed25519 signature scheme and verified directly on-chain. The lock identifies the owner via a 20-byte blake160 hash of the Ed25519 public key, which is derived from a base58-encoded Solana address.