### Install Dependencies and Start DApp (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Installs project dependencies using npm and then starts the development server for the dApp. This command is run from the 'frontend' directory. ```bash npm i && npm run dev ``` -------------------------------- ### Starting Local CKB Devnet with offckb (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/README.md Execute this command using the installed offckb tool to start a local CKB development network, which provides a blockchain environment for testing dApp examples. ```Shell offckb node ``` -------------------------------- ### Clone and Start Dapp Example (Generic) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/store-data-on-cell/README.md Clones the repository containing the example, navigates to the specific example directory, installs project dependencies using yarn, and starts the application. ```sh git clone https://github.com/nervosnetwork/docs.nervos.org.git cd docs.nervos.org/examples/store-data-on-cell yarn && yarn start ``` -------------------------------- ### Run CKB Example Application (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/dapp/_SetupProjectContent.mdx This command installs project dependencies using `yarn`, sets the `NETWORK` environment variable to `devnet`, and then starts the application using `yarn start`. This is typically used to run the example against a local development network. ```bash yarn && NETWORK=devnet yarn start ``` -------------------------------- ### Setup CKB Duktape Template (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/blog/intro-to-script-7.md Commands to clone the CKB Duktape template repository, navigate into the project directory, install necessary npm dependencies, and build the initial project to ensure the setup is working correctly. ```Shell export TOP=$(pwd) git clone https://github.com/xxuejie/ckb-duktape-template htlc-template cd htlc-template npm install npm run build ``` -------------------------------- ### Example Application Start Output (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/dapp/_SetupProjectContent.mdx This snippet shows the expected output when the example application is successfully started. It indicates that the `parcel` bundler is running, the server is available at `http://localhost:1234`, and the build process completed quickly. ```bash $ parcel index.html\nServer running at http://localhost:1234\n✨ Built in 66ms ``` -------------------------------- ### Setup and Run Omnilock-Solana Example (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/common-scripts/omnilock.mdx Commands to build the Lumos project, navigate to the Omnilock-Solana example directory, and start the example application. ```bash npm run build cd examples/omni-lock-solana npm start ``` -------------------------------- ### Installing offckb Globally (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/README.md Use npm to install the offckb command-line tool globally. This tool is required to start a local CKB development network. ```Shell npm install -g offckb ``` -------------------------------- ### Install OffCKB CLI - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs the OffCKB command-line interface globally using npm. OffCKB sets up a local CKB Devnet for testing dApps. ```bash npm install -g @offckb/cli ``` -------------------------------- ### Navigate to Frontend Directory (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Changes the current directory to the 'frontend' workspace, which is necessary before installing dependencies and starting the dApp. ```bash cd frontend ``` -------------------------------- ### Install Cargo-generate (≥0.17.0) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Install Cargo-generate, a tool to create new Rust projects from templates, simplifying project setup. Version ≥0.17.0 is recommended. ```bash cargo install cargo-generate ``` -------------------------------- ### Install Git (≥2.40.0) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Install Git, a version control system for tracking code changes. Version ≥2.40.0 is recommended. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install git ``` ```bash sudo apt install git ``` -------------------------------- ### Clone Repository and Start Dapp Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/simple-transfer/README.md Clones the example repository from GitHub, navigates into the simple-transfer directory, installs project dependencies using yarn, and starts the Dapp. ```Shell git clone https://github.com/nervosnetwork/docs.nervos.org.git cd docs.nervos.org/examples/simple-transfer yarn && yarn start ``` -------------------------------- ### Installing OffCKB CLI (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Installs the offCKB command-line interface globally using npm. This tool is essential for quickly setting up a local CKB development environment and using pre-built boilerplates. ```bash npm install -g @offckb/cli ``` -------------------------------- ### Clone Repository and Start App Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/create-dob/README.md Clones the example repository from GitHub, navigates into the Dapp directory, installs project dependencies using yarn, and then starts the application. ```Shell git clone https://github.com/nervosnetwork/docs.nervos.org.git cd docs.nervos.org/examples/create-dob yarn && yarn start ``` -------------------------------- ### Start CKB Devnet with offckb Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/xudt/README.md Uses the globally installed `offckb` tool to start a local CKB development network node. ```Shell offckb node ``` -------------------------------- ### OffCKB Project Creation Success Output (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Displays the console output indicating successful cloning and setup of the project template after selecting a framework during the `offckb create` process. ```bash Cloning into '/Users/Desktop/offckb/templates/temp-clone-folder'... Folder examples/next-js-template downloaded successfully from https://github.com/nervosnetwork/docs.nervos.org and moved to /Users/nervosDocs/Desktop/offckb/my-dapp-project ``` -------------------------------- ### Start Frontend Development Server Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/sdk-and-devtool/offckb.mdx Navigate into the frontend directory of your project, install dependencies, and start the local development server to run the frontend application. ```bash cd frontend && npm i & npm run dev ``` -------------------------------- ### Install offckb CLI Tool Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/store-data-on-cell/README.md Installs the 'offckb' command-line interface tool globally using npm. This tool is required to start and manage a local CKB development network (devnet). ```sh npm install -g offckb ``` -------------------------------- ### Setting up CKB Duktape Template - Shell Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/script-course/intro-to-script-7.md Provides the necessary shell commands to clone the CKB Duktape template repository from GitHub, navigate into the created directory, install project dependencies using npm, and build the project to ensure the setup is correct and functional. ```Shell export TOP=$(pwd) git clone https://github.com/xxuejie/ckb-duktape-template htlc-template cd htlc-template npm install # now you can try building the script first to ensure everything works npm run build ``` -------------------------------- ### CRA App Initialization Response Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Displays the output from the `create-react-app` command, indicating the successful creation of the React application directory, the installation of packages (react, react-dom, react-scripts), and the total time taken. ```bash Creating a new React app in /Users/nervosDocs/Desktop/offckb/my-cra-dapp. Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-template-typescript... added 1489 packages in 2m ``` -------------------------------- ### Run Dapp Example on CKB Devnet Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/store-data-on-cell/README.md Sets the NETWORK environment variable to 'devnet', changes the directory to the example folder, installs dependencies (if needed), and starts the application configured to connect to the local CKB devnet. ```sh export NETWORK=devnet cd write-and-read-message yarn && yarn start ``` -------------------------------- ### Setup CKB Script Debugger Environment (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/blog/intro-to-script-7.md Sets up the project directory and installs necessary Node.js packages for the CKB script debugging environment, including CKB SDK, Molecule, and CRC32. ```shell $ cd $TOP $ mkdir htlc-runner $ cd htlc-runner $ npm init $ npm install --save @nervosnetwork/ckb-sdk-core $ npm install --save @nervosnetwork/ckb-sdk-utils $ npm install --save molecule-javascript $ npm install --save crc32 ``` -------------------------------- ### Start CKB Devnet using offckb Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/store-data-on-cell/README.md Starts a local CKB development network node using the installed 'offckb' CLI tool. This command initiates a local blockchain environment for testing the Dapp. ```sh offckb node ``` -------------------------------- ### OffCKB Devnet Startup Output (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Shows the console output when starting the CKB Devnet with `offckb node`. It includes messages about downloading CKB if necessary, initializing the configuration, and the CKB node's initial output. ```bash /bin/sh: /Users/nervosDocs/.nvm/versions/node/v18.12.1/lib/node_modules/@offckb/cli/target/ckb/ckb: No such file or directory /Users/nervosDocs/.nvm/versions/node/v18.12.1/lib/node_modules/@offckb/cli/target/ckb/ckb not found, download and install the new version 0.113.1.. CKB installed successfully. init Devnet config folder: /Users/nervosDocs/.nvm/versions/node/v18.12.1/lib/node_modules/@offckb/cli/target/devnet modified /Users/nervosDocs/.nvm/versions/node/v18.12.1/lib/node_modules/@offckb/cli/target/devnet/ckb-miner.toml CKB output: 2024-03-20 07:56:44.765 +00:00 main INFO sentry sentry is disabled CKB output: 2024-03-20 07:56:44.766 +00:00 main INFO ckb_bin::helper raise_fd_limit newly-increased limit: 61440 CKB output: 2024-03-20 07:56:44.854 +00:00 main INFO ckb_bin::subcommand::run ckb version: 0.113.1 (95ad24b 2024-01-31) CKB output: 2024-03-20 07:56:45.320 +00:00 main INFO ckb_db_migration Init database version 20230206163640 CKB output: 2024-03-20 07:56:45.329 +00:00 main INFO ckb_launcher Touch chain spec hash: Byte32(0x3036c73473a371f3aa61c588c38924a93fb8513e481fa7c8d884fc4cf5fd368a) ``` -------------------------------- ### Install CKB-Debugger (≥0.113.0) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Install CKB-Debugger, a CLI tool for off-chain CKB Script development and testing. Version ≥0.113.0 is recommended. ```bash cargo install --git https://github.com/nervosnetwork/ckb-standalone-debugger ckb-debugger ``` -------------------------------- ### Starting the Local CKB Devnet with OffCKB (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Starts a local CKB development network (Devnet) using the offCKB CLI. This command makes the Devnet RPC endpoint available at `localhost:8114` for development and testing. ```bash offckb node ``` -------------------------------- ### Starting CKB Miner (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/blog/intro-to-script-7.md This simple shell script demonstrates how to navigate to the project directory and start a CKB miner instance using the previously initialized data directory. ```Shell $ cd $TOP $ $CKB miner -C ckb-data ``` -------------------------------- ### Creating a New dApp Project with OffCKB (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Initializes a new full-stack dApp project using the offCKB CLI. Replace with the desired project name. The command will prompt you to select a frontend framework. ```bash offckb create ``` -------------------------------- ### Build and Run Omnilock-Metamask Example (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/common-scripts/omnilock.mdx These commands build the project, create a release build, navigate into the specific Omnilock-Metamask example directory, and then start the example application. ```Shell npm run build npm run build-release cd examples/omni-lock-metamask npm start ``` -------------------------------- ### OffCKB Project Creation Prompt Output (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Shows the interactive prompt output when running `offckb create`, illustrating how to select a bare template using arrow keys from the available options. ```bash ? Select a bare template Remix-Vite Bare Templates > Next.js Bare Templates --- A full-stack template with Next.js framework and ckb-script-templates, [next.js,tailwindcss,ckb-script-templates,typescript,rust] ``` -------------------------------- ### Setting up CKB Debugger Environment (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/script-course/intro-to-script-7.md Commands to create a project directory, initialize npm, and install necessary CKB SDK and Molecule libraries for the CKB script debugging environment. ```shell $ cd $TOP $ mkdir htlc-runner $ cd htlc-runner $ npm init $ npm install --save @nervosnetwork/ckb-sdk-core $ npm install --save @nervosnetwork/ckb-sdk-utils $ npm install --save molecule-javascript $ npm install --save crc32 ``` -------------------------------- ### Install Make, Sed, Bash, Coreutils - MacOS - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs essential development tools (make, sed, bash, coreutils) on MacOS using Homebrew. These are needed for script development. ```bash brew install make gnu-sed bash coreutils ``` -------------------------------- ### Install Make, Sed, Bash, Coreutils - Linux - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs essential development tools (make, sed, bash, coreutils) on Debian/Ubuntu, Fedora, or ArchLinux using their respective package managers. These are needed for script development. ```bash sudo apt install make sed bash coreutils # Debian/Ubuntu sudo dnf install make sed bash coreutils # Fedora sudo pacman -S make sed bash coreutils # ArchLinux ``` -------------------------------- ### Install Scoop - Windows - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Configures execution policy and installs the Scoop package manager on Windows using PowerShell. Scoop is a prerequisite for installing Rust. ```bash Set-ExecutionPolicy RemoteSigned -Scope CurrentUser iwr -useb get.scoop.sh | iex ``` -------------------------------- ### Install Rust - Windows - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs the Rust toolchain on Windows using the Scoop package manager. Rust is needed for CKB script development. ```bash scoop install rust ``` -------------------------------- ### Starting CKB Dev Chain (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/script-course/intro-to-script-7.md This shell script snippet sets up the environment and starts a CKB development chain instance. It navigates directories, exports the CKB binary path, checks the version, initializes a dev chain data directory, and runs the CKB node. ```Shell $ cd $TOP $ export CKB="" $ $CKB --version ckb 0.28.0 (728eff2 2020-02-04) # Block assembler args configured here correspond to the following private key: # 0x0a14c6fd7af6a3f13c9e2aacad80d78968de5d068a342828080650084bf20104 $ $CKB init -c dev -C ckb-data --ba-arg 0x5a7487f529b8b8fd4d4a57c12dc0c70f7958a196 $ $CKB run -C ckb-data ``` -------------------------------- ### Install Rustup - Linux - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs the Rust toolchain manager (rustup) on Linux using the official rustup script. Rust is needed for CKB script development. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### offckb Inject Config Response Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Shows the output after running `offckb inject-config`, confirming that the configuration was successfully injected. It also provides examples of how to import and use the generated `offckb.config` object to access script code hashes within the project. ```bash All good. You can now use it in your project like: import offCKB from "offckb.config"; const myScriptCodeHash = offCKB.myScripts['script-name'].codeHash; const omnilockScriptCodeHash = offCKB.systemScripts['omnilock'].codeHash; Check example at https://github.com/nervosnetwork/docs.nervos.org/tree/develop/examples/simple-transfer ``` -------------------------------- ### Install offckb CLI Tool Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/xudt/README.md Installs the `offckb` command-line interface tool globally using npm, which is used for managing CKB devnets. ```Shell npm install -g offckb ``` -------------------------------- ### Creating a Script-Only Project with OffCKB (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Initializes a project focused solely on CKB Script development without a frontend using the `offckb` CLI with the `--script` flag. Replace with the desired project name. ```bash offckb create --script ``` -------------------------------- ### Starting OffCKB Devnet Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/script/spawn-script.mdx Starts a local CKB Devnet node using the offckb tool, providing an environment for testing scripts and transactions. ```sh offckb node ``` -------------------------------- ### Build ckb-js-vm Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Build ckb-js-vm, which allows writing and executing Scripts within the CKB-VM using the QuickJS engine. This involves cloning the repository, updating submodules, and building. ```bash git clone https://github.com/nervosnetwork/ckb-js-vm cd ckb-js-vm git submodule update --init make all ``` -------------------------------- ### Install Yarn (≥1.22.0) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Install Yarn, a package manager for JavaScript projects. Version ≥1.22.0 is recommended. This command uses npm for installation. ```bash npm install --global yarn ``` -------------------------------- ### Deploy Scripts to Testnet (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Deploys the built CKB scripts to the Testnet using the `offckb` command-line tool. This command is executed from the frontend workspace. ```sh offckb deploy --network testnet ``` -------------------------------- ### Install Rustup - MacOS - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs the Rust toolchain manager (rustup) on MacOS using Homebrew. Rust is needed for CKB script development. ```bash brew install rustup ``` -------------------------------- ### Clone and Run CKB Token Dapp Locally Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/xudt/README.md Clones the repository containing the Dapp example, navigates to the example directory, and starts the application using yarn for local execution. ```Shell git clone https://github.com/nervosnetwork/docs.nervos.org.git cd docs.nervos.org/examples/xudt yarn && yarn start ``` -------------------------------- ### Install npm (Node.js v20.18.0 LTS) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Install npm (Node.js package manager) along with Node.js. Version v20.18.0 LTS is recommended for managing project dependencies. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install node@20.18.0 ``` ```bash curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt install -y nodejs ``` -------------------------------- ### Install CCC Connector - Web Component - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs the CKB-CCC connector package for Web Component usage using npm. CCC is used for interacting with CKB. ```bash npm install @ckb-ccc/connector ``` -------------------------------- ### Deploy Scripts to Devnet (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Deploys the built CKB scripts to the Devnet using the `offckb` command-line tool. This command is executed from the frontend workspace. ```sh offckb deploy --network devnet ``` -------------------------------- ### Install Library, Build, and Run CKB Script (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/blog/intro-to-script-7.md Sequence of shell commands to navigate to the project directory, install the `crc32` npm package, build the script, navigate to the runner directory, and execute the script with debugging enabled, showing the resulting debug output. ```Shell $ cd $TOP/htlc-template $ npm install --save crc32 $ npm run build $ cd $TOP/htlc-runner $ RUST_LOG=debug `./runner.js ../ckb-duktape/build/load0 ../htlc-template/build/duktape.js` DEBUG:: script group: Byte32(0x35ab3d033e66c426573ed4b7ce816e248cb042d908fd8cfe7bba27acb37fb108) DEBUG OUTPUT: c: 0x970dd9a8 DEBUG:: script group: Byte32(0x35ab3d033e66c426573ed4b7ce816e248cb042d908fd8cfe7bba27acb37fb108) DEBUG OUTPUT: 970dd9a8 Run result: Ok(0) ``` -------------------------------- ### Starting Frontend Development Server (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/simple-lock/README.md Navigates into the frontend project directory and runs the standard `npm run dev` command to start the local development server for the Dapp. ```bash cd frontend npm run dev ``` -------------------------------- ### Install offckb CLI Tool Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/simple-transfer/README.md Installs the offckb command-line interface tool globally using npm. This tool is used to start and manage a local CKB development network. ```Shell npm install -g offckb ``` -------------------------------- ### Start CKB Devnet using offckb Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/simple-transfer/README.md Starts a local CKB development network node using the globally installed offckb CLI tool. This provides a local blockchain environment for testing. ```Shell offckb node ``` -------------------------------- ### Install CCC - Custom UI - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs the main CKB-CCC JavaScript SDK package for custom UI implementations using npm. CCC is used for interacting with CKB. ```bash npm install @ckb-ccc/ccc ``` -------------------------------- ### Install offckb CLI Tool Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/create-dob/README.md Installs the 'offckb' command-line interface tool globally using npm. This tool is used to easily start and manage a local CKB development network. ```Shell npm install -g offckb ``` -------------------------------- ### Install Homebrew - MacOS - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs the Homebrew package manager on MacOS using a curl script. This is a prerequisite for installing other tools like Make, Sed, Bash, Coreutils, and Rust. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Run Dapp Example on CKB Testnet Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/store-data-on-cell/README.md Sets the NETWORK environment variable to 'testnet', changes the current directory to the write-and-read-message example folder, and starts the application configured to connect to the CKB testnet. ```sh export NETWORK=testnet cd write-and-read-message yarn start ``` -------------------------------- ### Navigate to App Directory and Inject offckb Config Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Changes the current directory to the newly created React application folder ('my-cra-dapp') and then runs the `offckb inject-config` command to integrate the offCKB configuration files and settings into the project structure. ```bash cd my-cra-dapp offckb inject-config ``` -------------------------------- ### Install CCC Core - NodeJS - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs the core CKB-CCC JavaScript SDK package for Node.js environments using npm. CCC is used for interacting with CKB. ```bash npm install @ckb-ccc/core ``` -------------------------------- ### OffCKB Help Output Example Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/sdk-and-devtool/offckb.mdx This code block shows an example of the output generated by running `offckb --help`, listing the various commands available within the OffCKB CLI for managing the CKB development environment. ```bash Usage: offckb [options] [command] ckb development network for your first try Options: -V, --version output the version number -h, --help display help for command Commands: create [options] [your-project-name] Create a new dApp from bare templates node [options] [CKB-Version] Use the CKB to start devnet proxy-rpc [options] Start the rpc proxy server clean Clean the devnet data, need to stop running the chain first accounts Print account list info list-hashes [CKB-Version] Use the CKB to list blockchain scripts hashes inject-config Add offckb.config.ts to your frontend workspace sync-scripts Sync scripts json files in your frontend workspace deposit [options] [toAddress] [amountInCKB] Deposit CKB tokens to address, only devnet and testnet transfer [options] [toAddress] [amountInCKB] Transfer CKB tokens to address, only devnet and testnet transfer-all [options] [toAddress] Transfer All CKB tokens to address, only devnet and testnet balance [options] [toAddress] Check account balance, only devnet and testnet deploy [options] Deploy contracts to different networks, only supports devnet and testnet my-scripts [options] Show deployed contracts info on different networks, only supports devnet and testnet config [item] [value] do a configuration action debug [options] CKB Debugger for development system-scripts [options] Output system scripts of the local devnet mol [options] Generate CKB Moleculec binding code for development repl [options] A custom Nodejs REPL environment bundle for CKB. help [command] display help for command ``` -------------------------------- ### Install CKB-SDK-Go Dependency (bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/sdk-and-devtool/go.mdx Adds the `ckb-sdk-go` library as a dependency to the Go project using the `go get` command, fetching the specified version (v2) from the repository. ```bash go get -v github.com/nervosnetwork/ckb-sdk-go/v2 ``` -------------------------------- ### Example Output: CKB Initialization Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/node/run-testnet-node.mdx Illustrative output showing the result of initializing the CKB directory and configuration files for the testnet. ```bash WARN: Mining feature is disabled because of lacking the block assembler config options. Initialized CKB directory in /PATH/0.115.0 create ckb.toml create ckb-miner.toml ``` -------------------------------- ### Install CCC Connector React - React - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Installs the CKB-CCC connector package specifically for React applications using npm. CCC is used for interacting with CKB. ```bash npm install @ckb-ccc/connector-react ``` -------------------------------- ### Development Server Startup Output (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/README.md Shows the expected output in the console after successfully running 'yarn start', indicating that the Docusaurus website is running and the local URL to access it. ```bash [INFO] Starting the development server... [SUCCESS] Docusaurus website is running at: http://localhost:3000/ ``` -------------------------------- ### Setup Project Directory - Lumos - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/sdk-and-devtool/lumos.mdx Creates a new directory named `lumos-example`, navigates into it, and initializes a new pnpm project with default settings (`-y`). This sets up the basic project structure. ```Bash mkdir lumos-example cd lumos-example pnpm init -y ``` -------------------------------- ### Starting CKB Miner (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/script-course/intro-to-script-7.md This shell script snippet shows how to start a CKB miner instance connected to the dev chain data directory. It navigates to the project root and executes the `ckb miner` command, specifying the data directory. ```Shell $ cd $TOP $ $CKB miner -C ckb-data ``` -------------------------------- ### Initializing CKB Script Project with offckb (Response) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/script/spawn-script.mdx This output shows the result of running `offckb create`. It confirms the project name, destination directory, template generation, file movement, and Git initialization, indicating a successful project setup. ```bash ⚠️ Favorite `gh:cryptape/ckb-script-templates` not found in config, using it as a git repository: https://github.com/cryptape/ckb-script-templates.git 🤷 Project Name: spawn-script 🔧 Destination: /tmp/spawn-script ... 🔧 project-name: spawn-script ... 🔧 Generating template ... 🔧 Moving generated files into: `/tmp/spawn-script`... 🔧 Initializing a fresh Git repository ✨ Done! New project created /tmp/spawn-script ``` -------------------------------- ### Start Dapp on CKB Devnet Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/simple-transfer/README.md Sets the NETWORK environment variable to 'devnet' to configure the Dapp to connect to a local CKB development network, changes directory to simple-transfer, installs dependencies (if necessary), and starts the Dapp. ```Shell export NETWORK=devnet cd simple-transfer yarn && yarn start ``` -------------------------------- ### Install Clang Compiler (≥v18) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Install the Clang compiler, essential for building CKB Scripts. Version ≥18 is required for compatibility with CKB tools. Instructions cover MacOS, Linux (Debian/Ubuntu, Fedora, Arch), and Windows. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install llvm@18 ``` ```bash wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 18 && rm llvm.sh # Debian/Ubuntu sudo dnf -y install clang # Fedora sudo pacman --noconfirm -Syu clang # ArchLinux ``` ```bash Set-ExecutionPolicy RemoteSigned -Scope CurrentUser iwr -useb get.scoop.sh | iex scoop install llvm yasm ``` -------------------------------- ### Starting OffCKB REPL Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/script/spawn-script.mdx Starts the offckb Read-Eval-Print Loop (REPL) with the '-r' flag, likely enabling features for interacting with the Devnet and CKB SDK. ```sh offckb repl -r ``` -------------------------------- ### Run CKB Token Dapp on Testnet Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/xudt/README.md Sets the NETWORK environment variable to 'testnet', navigates to the Dapp directory, and starts the application configured for the CKB testnet. ```Shell export NETWORK=testnet cd xudt yarn start ``` -------------------------------- ### Debug Full CKB Transaction with offckb Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Use this command to debug an entire CKB transaction by providing its hash. The tool verifies all scripts and outputs detailed execution information, including cycle consumption for each script. ```Shell offckb debug ``` -------------------------------- ### Debug Single CKB Script with Local Binary Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Replace the script being debugged with a local binary file for testing purposes. This command requires the transaction hash, the target script specified by --single-script, and the path to the binary file using the --bin option. ```Shell offckb debug --single-script --bin ``` -------------------------------- ### Initialize React App with TypeScript using CRA Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Initializes a new React application named 'my-cra-dapp' using Create React App (CRA) with the TypeScript template. This command sets up the basic project structure and installs necessary dependencies for a TypeScript-based React project. ```bash npx create-react-app my-cra-dapp --template typescript ``` -------------------------------- ### Start CKB Testnet Node Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/node/run-testnet-node.mdx Execute the command to start the CKB node and begin syncing with the Pudge Testnet. ```bash ckb run ``` -------------------------------- ### Running Frontend DApp (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/dapp/simple-lock.mdx Navigates to the frontend directory, installs Node.js dependencies using `npm i`, and starts the development server for the Next.js application using `npm run dev`. This makes the web interface accessible locally. ```bash cd frontend && npm i && npm run dev ``` ```text > frontend@0.1.0 dev > next dev ▲ Next.js 14.2.3 - Local: http://localhost:3000 - Environments: .env ✓ Starting... ✓ Ready in 1631ms ``` -------------------------------- ### offckb Sync Scripts Response Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Displays the confirmation message after running `offckb sync-scripts`, indicating that the scripts JSON configuration file has been successfully updated within the frontend project. ```bash scripts json config updated. ``` -------------------------------- ### OffCKB Config List Output Example Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/sdk-and-devtool/offckb.mdx This JSON object shows an example output of the `offckb config list` command, highlighting the structure and key paths for devnet configuration and data. ```json { "devnet": { "rpcUrl": "", "configPath": "~/Library/Application Support/offckb-nodejs/devnet", "dataPath": "~/Library/Application Support/offckb-nodejs/devnet/data" } } ``` -------------------------------- ### Run CKB Token Dapp on Devnet Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/xudt/README.md Sets the NETWORK environment variable to 'devnet', navigates to the Dapp directory, and starts the application configured for the local CKB devnet. ```Shell export NETWORK=devnet cd xudt yarn && yarn start ``` -------------------------------- ### Setup CKB-SDK-Go Client (Go) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/sdk-and-devtool/go.mdx Demonstrates how to import the necessary RPC package and establish a connection to a CKB node (Testnet, Devnet, or Mainnet) by providing the appropriate URL to the `rpc.Dial` function. ```Go import ( "github.com/nervosnetwork/ckb-sdk-go/v2/rpc" ) testnetURL := "https://testnet.ckb.dev" // Testnet devnetURL := "http://127.0.0.1:8114" // Devnet mainnetURL := "https://mainnet.ckb.dev/rpc" // Mainnet // Connect to Testnet ckbClient, err := rpc.Dial(testnetURL) ``` -------------------------------- ### Starting Devnet with offckb CLI (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/dapp/_StartDevnet.mdx This command starts the CKB Devnet using the offckb CLI. It initializes the configuration, downloads necessary binaries if missing, and begins running the CKB node and miner. The output shows the initialization process and node version. ```bash offckb node ``` -------------------------------- ### Sync Deployed Scripts Configuration with offckb Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Executes the `offckb sync-scripts` command in the frontend project's root directory. This command updates the `offckb.config.ts` file with the latest information about the deployed CKB scripts, ensuring the frontend uses the correct script hashes and details. ```bash offckb sync-scripts ``` -------------------------------- ### Run CKB Script and Start REPL (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/script-course/intro-to-script-7.md Shows the shell command to execute the `runner.js` script using the `repl0` Duktape binary instead of `load0`. This runs the script and then drops into a Duktape REPL (Read-Eval-Print Loop) for interactive debugging and testing. ```Shell $ cd $TOP/htlc-runner $ RUST_LOG=debug `./runner.js ../ckb-duktape/build/repl0 ../htlc-template/build/duktape.js` duk> ``` -------------------------------- ### Starting Development Server (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/integrate-wallets/ccc-wallet.mdx Starts the local development server for the project, typically configured to run on `http://localhost:3000`, allowing you to view and test the application. ```Bash pnpm run dev ``` -------------------------------- ### Manage OffCKB Network Proxy Configuration Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/sdk-and-devtool/offckb.mdx Provides examples for setting, getting, and removing the network proxy configuration using the OffCKB config commands. ```bash offckb config set proxy > save new settings offckb config get proxy > offckb config rm proxy > save new settings offckb config get proxy > No Proxy. ``` -------------------------------- ### Deploying HTLC Scripts and Testing Unlock (Shell) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/script-course/intro-to-script-7.md This comprehensive shell script snippet guides the user through building the HTLC template, making runner scripts executable, deploying necessary scripts to the CKB dev chain, creating an HTLC cell, and demonstrating dry-running unlock transactions using both secret string and timeout methods. Includes example command outputs. ```Shell # Make sure the HTLC script is successfully built first $ cd $TOP/htlc-template $ npm run build # Ensure all scripts are runnable $ cd $TOP/htlc-runner $ chmod +x deploy_scripts.js $ chmod +x create_htlc_cell.js $ chmod +x unlock_via_secret_string.js $ chmod +x unlock_via_timeout.js # Let's first deploy duktape binary and JS scripts $ ./deploy_scripts.js \ ../ckb-duktape/build/load0 \ ../htlc-template/build/duktape.js \ 0xd00c06bfd800d27397002dca6fb0993d5ba6399b4238b2f29ee9deb97593d2bc \ "http://127.0.0.1:8114/" This method is only for demo, don't use it in production Transaction hash: 0xf30e1e8989fc3a4cb1e52dacc85090f8ff74b05e008d636b8c9154f5c296e1f4 # Let's create a HTLC cell $ ./create_htlc_cell.js \ ../ckb-duktape/build/load0 \ 0xf30e1e8989fc3a4cb1e76976d1d55edf844c4fa81485e00fb8eba2d161b5830cd \ 0xd00c06bfd800d27397002dca6fb0993d5ba6399b4238b2f29ee9deb97593d2bc \ "http://127.0.0.1:8114/" \ 0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947 \ 0xc219351b150b900e50a7039f1e448b844110927e5fd9bd30425806cb8ddff1fd This method is only for demo, don't use it in production Transaction hash: 0x7de8ea6b0d6cb9941e76976d1d55edf844c4fa81485e00fb8eba2d161b5830cd # To save us the hassle of recreating cells, both unlock executables support # a dry run mode, where we only does full transaction verification, but do not # commit the success ones on chain. # First let's show that we can unlock a HTLC cell given the right secret string # and lock script $ ./unlock_via_secret_string.js \ 0xf30e1e8989fc3a4cb1e52dacc85090f8ff74b05e008d636b8c9154f5c296e1f4 \ 0x7de8ea6b0d6cb9941e76976d1d55edf844c4fa81485e00fb8eba2d161b5830cd \ 0xd00c06bfd800d27397002dca6fb0993d5ba6399b4238b2f29ee9deb97593d2bc \ "http://127.0.0.1:8114/" \ "i am a secret" \ true This method is only for demo, don't use it in production Dry run success result: { "cycles": "0xb1acc38" } ``` -------------------------------- ### Cleaning Local CKB Devnet Data with OffCKB (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Removes the local CKB Devnet data directory managed by offCKB. This command is used to reset the Devnet to a fresh state before starting the node again. ```bash offckb clean ``` -------------------------------- ### Setting up Development Environment for CKB WASM Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/blog/intro-to-script-8.md These shell commands prepare the development environment by cloning required repositories (AssemblyScript, wabt, WAVM, wavm-aot-generator, ckb-standalone-debugger, ckb-binary-patcher, ckb-c-stdlib) and building necessary tools using npm, cmake, and cargo. This setup is required to follow the examples demonstrating performant WASM on CKB. ```Shell $ export TOP=$(pwd) $ git clone https://github.com/AssemblyScript/assemblyscript.git $ cd assemblyscript $ git checkout b433bc425633c3df6a4a30c735c91c78526a9eb7 $ npm install $ cd $TOP $ git clone --recursive https://github.com/WebAssembly/wabt $ cd wabt $ git checkout bec78eafbc203d81b9a6d1ce81f5a80dd7bf692a $ mkdir build $ cd build $ cmake .. $ cmake --build . $ cd $TOP $ git clone https://github.com/xxuejie/WAVM $ cd WAVM $ git checkout cb35225feeb4ba1b5a9c73cbbdb07f4cace9b359 $ mkdir build $ cd build # Make sure you are using LLVM 9+, you might need to tweak this path depending # on your environment $ cmake .. -DLLVM_DIR=/usr/lib/llvm-9/lib/cmake/llvm $ cmake --build . $ cd $TOP $ git clone https://github.com/xxuejie/wavm-aot-generator $ cd wavm-aot-generator $ git checkout 8c818747eb19494fc9c5e0289810aa7ad484a22e $ cargo build --release $ cd $TOP $ git clone https://github.com/xxuejie/ckb-standalone-debugger $ cd ckb-standalone-debugger $ git checkout 15e8813b8cb886e95e2c81bbee9f26d47a831850 $ cd bins $ cargo build --release $ cd $TOP $ git clone https://github.com/xxuejie/ckb-binary-patcher $ cd ckb-binary-patcher $ git checkout 930f0b468a8f426ebb759d9da735ebaa1e2f98ba $ cd ckb-binary-patcher $ cargo build --release $ cd $TOP $ git clone https://github.com/nervosnetwork/ckb-c-stdlib $ cd ckb-c-stdlib $ git checkout 693c58163fe37d6abd326c537447260a846375f0 ``` -------------------------------- ### Import and Use Deployed Scripts (TypeScript) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Demonstrates how to import the `offckb.config` file and access details of deployed scripts, such as `cellDeps`, `codeHash`, and `hashType`, to construct a CKB `Script` object for use in the frontend dApp. ```typescript import offckb from "offckb.config"; const myScriptDeps: CellDep[] = offCKB.myScripts["YOUR_SCRIPT_NAME"]!.cellDeps; const myScript: Script = { codeHash: offCKB.myScripts["hash-lock"]!.codeHash, hashType: offCKB.myScripts["hash-lock"]!.hashType, args: lockArgs, }; ``` -------------------------------- ### Install Website Dependencies (Yarn/Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/README.md Shows the bash command to install the necessary Node.js dependencies for the Docusaurus website using the Yarn package manager. This command should be run inside the 'website' directory. ```bash yarn install ``` -------------------------------- ### Start Dapp on CKB Testnet Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/simple-transfer/README.md Sets the NETWORK environment variable to 'testnet' to configure the Dapp to connect to the CKB testnet, changes directory to simple-transfer, and starts the Dapp. ```Shell export NETWORK=testnet cd simple-transfer yarn start ``` -------------------------------- ### Add RISC-V Target - Windows - Bash Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/installation.mdx Adds the riscv64imac-unknown-none-elf target to the Rust toolchain using rustup. This target is required for compiling CKB scripts on Windows. ```bash rustup target add riscv64imac-unknown-none-elf ``` -------------------------------- ### Cloning Repository and Navigating Directory (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/dapp/simple-lock.mdx Clones the project repository from GitHub and changes the current directory to the simple-lock example folder. This is the first step to set up the project locally. ```bash git clone https://github.com/nervosnetwork/docs.nervos.org.git cd docs.nervos.org/examples/simple-lock ``` -------------------------------- ### OffCKB Devnet Data Clean Output (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/getting-started/quick-start.mdx Shows the console output confirming that the local CKB Devnet chain data has been successfully removed by the `offckb clean` command. ```bash Chain data cleaned. ``` -------------------------------- ### Loading Code from GitHub Raw Source via URL Parameter (Example) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/sdk-and-devtool/playground.mdx This bash example demonstrates the general format for loading code into the CCC Playground directly from a raw source URL (like GitHub) by appending the '?src=' parameter to the playground's base URL. ```Bash https://live.ckbccc.com/?src=https://raw.githubusercontent.com/your-repo/your-file.ts ``` -------------------------------- ### Install OffCKB CLI via npm Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/sdk-and-devtool/offckb.mdx Installs the OffCKB command-line interface globally using npm, making the `offckb` command available in your terminal for use in any directory. ```bash npm install -g @offckb/cli ``` -------------------------------- ### Run App on Devnet Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/create-dob/README.md Sets the NETWORK environment variable to 'devnet', navigates to the Dapp directory, installs dependencies if needed, and starts the application configured for the local CKB development network. ```Shell export NETWORK=devnet cd create-dob yarn && yarn start ``` -------------------------------- ### Installing Project Dependencies (Bash) Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/integrate-wallets/ccc-wallet.mdx Installs all required project dependencies listed in the `package.json` file using the pnpm package manager. ```Bash pnpm install ``` -------------------------------- ### Generated C Code from ZetZ Example Source: https://github.com/nervosnetwork/docs.nervos.org/blob/develop/website/docs/script-course/intro-to-script-10.md Presents the C code generated by the ZetZ compiler from the carrot example. It shows that the generated code is clean, efficient, and lacks any runtime overhead related to the theorem proving checks, which are performed at build time. ```C #include #include #include static int ckb_zz_demo_main_load_data(uint64_t const index, uint8_t* const buffer); #include int __attribute__((visibility("default"))) ckb_zz_demo_main_main(); #include static int ckb_zz_demo_main_load_data(uint64_t const index, uint8_t* const buffer); int main() { uint64_t const index = 0; while (true) { uint8_t const buffer[6]; int const ret = ckb_zz_demo_main_load_data(index, buffer); if ((ret == 1)) { break; } if ((memcmp(buffer, "carrot", 6) == 0)) { return -1; } (index++); } return 0; } static int ckb_zz_demo_main_load_data(uint64_t const index, uint8_t* const buffer) { uint64_t l = 6; int const ret = (int)(ckb_load_cell_data(buffer, (&l), 0, index, 2)); return ret; } ```