diff --git a/website/docs/getting-started/installation.mdx b/website/docs/getting-started/installation.mdx index bdecce5a7..b3a7709c2 100644 --- a/website/docs/getting-started/installation.mdx +++ b/website/docs/getting-started/installation.mdx @@ -14,9 +14,9 @@ This installation guide provides a step-by-step setup of all essential tools nee This section covers the essential tools you need to develop CKB applications, including setting up the local development environment and JavaScript SDK. -### 1. OffCKB (≥v0.3.0-rc2) +### 1. OffCKB (≥v0.3.0) -OffCKB sets up a local CKB Devnet, allowing you to test dApps without connecting to the main network. We recommend using **≥v0.3.0-rc2**. +OffCKB sets up a local CKB Devnet, allowing you to test dApps without connecting to the main network. We recommend using **≥v0.3.0**. ```bash npm install -g @offckb/cli diff --git a/website/docs/getting-started/quick-start.mdx b/website/docs/getting-started/quick-start.mdx index 2af1e8540..b9aee3ec4 100644 --- a/website/docs/getting-started/quick-start.mdx +++ b/website/docs/getting-started/quick-start.mdx @@ -21,7 +21,7 @@ npm install -g @offckb/cli ``` :::info -Throughout this documentation, we use offckb/cli version **>=0.3.0-rc2**. You can always run the above command to update to the latest version. +Throughout this documentation, we use offckb/cli version **>=0.3.0**. You can always run the above command to update to the latest version. ::: ## Create a New Project @@ -159,7 +159,7 @@ npm i && npm run dev Once the server is up and running, you can view the dApp by visiting [localhost:3000](http://localhost:3000). You can start editing the page by modifying `app/page.tsx`. As you make changes to the file, the page will automatically update to reflect your edits. For detailed instructions on how to start the dApp and explore additional config options, please see the `README.md` file. -![dapp-screenshot](/img/quick-start/next-js-dapp.jpg) +![dapp-screenshot](/img/quick-start/remix-vite-dapp.png) --- diff --git a/website/docs/sdk-and-devtool/ckb-cli.mdx b/website/docs/sdk-and-devtool/ckb-cli.mdx new file mode 100644 index 000000000..09baee8bd --- /dev/null +++ b/website/docs/sdk-and-devtool/ckb-cli.mdx @@ -0,0 +1,83 @@ +--- +id: ckb-cli +title: CKB-CLI +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import Tooltip from "@components/Tooltip"; + +# CKB-CLI + +[ckb-cli](https://github.com/nervosnetwork/ckb-cli) is a CKB command-line tool developed in Rust. + +If you need to interact with Mainnet blockchain from the command line, `ckb-cli` is an ideal choice to manage accounts, deploy Scripts and send Transactions. + +### Features + +``` + rpc Invoke RPC call to node + account Manage accounts + mock-tx Handle mock transactions (verify/send) + tx Handle common sighash/multisig transaction + util Utilities + molecule Molecule encode/decode utilities + wallet Transfer / query balance (with local index) / key utils + dao Deposit / prepare / withdraw / query NervosDAO balance (with local index) / key utils +``` + +All second-level sub-commands are listed on the [wiki page](https://github.com/nervosnetwork/ckb-cli/wiki/Sub-Commands). + +### Install + +``` +git clone https://github.com/nervosnetwork/ckb-cli.git +cd ckb-cli +cargo install --path . -f --locked +``` + +### Usage + +Better export an env first (or give in argument) + +``` +export API_URL=http://127.0.0.1:8114 +``` + +Directly go to **gorgeous** interactive mode: + +``` +ckb-cli +``` + +Show available commands + +```shell +# Top level help doc +ckb-cli --help +# RPC help doc +ckb-cli rpc --help +``` + +#### Example: Get Live Cell (JSON Output Format) + +``` +ckb-cli rpc get_live_cell --tx-hash 0x4ec75b5a8de8d180853d5046760a99285c73283a5dc528f81d6ee056f5335172 --index 0 +``` + +**Response:** + +```json +{ + "cell": { + "capacity": "125000000000", + "lock": { + "args": ["0x64257f00b6b63e987609fa9be2d0c86d351020fb"], + "code_hash": "0x1892ea40d82b53c678ff88312450bbb17e164d7a3e0a90941aa58839f56f8df2", + "hash_type": "type" + }, + "type": null + }, + "status": "live" +} +``` diff --git a/website/docs/sdk-and-devtool/cli-tool.mdx b/website/docs/sdk-and-devtool/cli-tool.mdx deleted file mode 100644 index 37d1bb891..000000000 --- a/website/docs/sdk-and-devtool/cli-tool.mdx +++ /dev/null @@ -1,269 +0,0 @@ ---- -id: cli-tools -title: CLI Tools ---- - -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; -import Tooltip from "@components/Tooltip"; - -# CLI Tools - -Command-line tools are often used by developers to perform specific blockchain tasks in a faster and more efficient way. - -## CKB-CLI - -[ckb-cli](https://github.com/nervosnetwork/ckb-cli) is a CKB command-line tool developed in Rust. - -If you need to interact with Mainnet blockchain from the command line, `ckb-cli` is an ideal choice to manage accounts, deploy Scripts and send Transactions. - -### Features - -``` - rpc Invoke RPC call to node - account Manage accounts - mock-tx Handle mock transactions (verify/send) - tx Handle common sighash/multisig transaction - util Utilities - molecule Molecule encode/decode utilities - wallet Transfer / query balance (with local index) / key utils - dao Deposit / prepare / withdraw / query NervosDAO balance (with local index) / key utils -``` - -All second-level sub-commands are listed on the [wiki page](https://github.com/nervosnetwork/ckb-cli/wiki/Sub-Commands). - -### Install - -``` -git clone https://github.com/nervosnetwork/ckb-cli.git -cd ckb-cli -cargo install --path . -f --locked -``` - -### Usage - -Better export an env first (or give in argument) - -``` -export API_URL=http://127.0.0.1:8114 -``` - -Directly go to **gorgeous** interactive mode: - -``` -ckb-cli -``` - -Show available commands - -```shell -# Top level help doc -ckb-cli --help -# RPC help doc -ckb-cli rpc --help -``` - -#### Example: Get Live Cell (JSON Output Format) - -``` -ckb-cli rpc get_live_cell --tx-hash 0x4ec75b5a8de8d180853d5046760a99285c73283a5dc528f81d6ee056f5335172 --index 0 -``` - -**Response:** - -```json -{ - "cell": { - "capacity": "125000000000", - "lock": { - "args": ["0x64257f00b6b63e987609fa9be2d0c86d351020fb"], - "code_hash": "0x1892ea40d82b53c678ff88312450bbb17e164d7a3e0a90941aa58839f56f8df2", - "hash_type": "type" - }, - "type": null - }, - "status": "live" -} -``` - -## OffCKB - -[offckb](https://github.com/ckb-devrel/offckb) is a CLI tool developed in Node.js to help you quickly set up a predefined CKB Devnet and create dApp boilerplates. - -If you need a local development environment for the very first try on your dApp, `offckb` is the ideal choice. - -### Install - -```sh -npm install -g @offckb/cli -``` - -### Usage - -```sh -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 [your-project-name] Create a new dApp from bare templates - node Use the CKB to start devnet - clean Clean the devnet data, need to stop running the chain first - accounts Print account list info - list-hashes Use the CKB to list blockchain scripts hashes - inject-config Add offckb.config.ts to your workspace - sync-config sync offckb.config.ts in your workspace - deposit [options] [toAddress] [amountInShannon] Deposit CKB tokens to address, only devnet and testnet - transfer [options] [toAddress] [amountInShannon] Transfer 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 - deployed-scripts [options] Show deployed contracts info on networks, only supports devnet and testnet - help [command] display help for command -``` - -#### Create a Full-Stack Project - -Create a new project from predefined boilerplates. - -```sh -offckb create -``` - -The boilerplate can target on different CKB networks. Check the [README.md](https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/remix-vite-template/readme.md) in the project to get started. - -#### Access Testing Accounts - -`offckb` provides 20 pre-funded accounts for use on Devnet. Each account is funded with 42,000,000,000,000,000 capacity in the Devnet's genesis block. You can access these accounts and copy the private keys and addresses for use when developing your dApps. - -```mdx-code-block - - -``` - -```bash -offckb accounts -``` - -```mdx-code-block - - -``` - -```bash -#### ALL ACCOUNTS ARE FOR TEST AND DEVELOP ONLY #### -#### DON'T USE THESE ACCOUNTS ON MAINNET #### -#### OTHERWISE YOU WILL LOOSE YOUR MONEY #### - -Print account list, each account is funded with 42_000_000_00000000 capacity in the devnet genesis block. - -- "#": 0 -address: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqvwg2cen8extgq8s5puft8vf40px3f599cytcyd8 -privkey: 0x6109170b275a09ad54877b82f7d9930f88cab5717d484fb4741ae9d1dd078cd6 -pubkey: 0x02025fa7b61b2365aa459807b84df065f1949d58c0ae590ff22dd2595157bffefa -lock_arg: 0x8e42b1999f265a0078503c4acec4d5e134534297 -lockScript: - codeHash: 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8 - hashType: type - args: 0x8e42b1999f265a0078503c4acec4d5e134534297 - -- "#": 1 -address: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqt435c3epyrupszm7khk6weq5lrlyt52lg48ucew -privkey: 0x9f315d5a9618a39fdc487c7a67a8581d40b045bd7a42d83648ca80ef3b2cb4a1 -pubkey: 0x026efa0579f09cc7c1129b78544f70098c90b2ab155c10746316f945829c034a2d -lock_arg: 0x758d311c8483e0602dfad7b69d9053e3f917457d -lockScript: - codeHash: 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8 - hashType: type - args: 0x758d311c8483e0602dfad7b69d9053e3f917457d - -- "#": 2 -address: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqvarm0tahu0qfkq6ktuf3wd8azaas0h24c9myfz6 -privkey: 0x59ddda57ba06d6e9c5fa9040bdb98b4b098c2fce6520d39f51bc5e825364697a -pubkey: 0x02f1ec8d18e8ff13ecf7b3ab8f683d0c3a6d63478a7f7d14ca0fdfe8fea331e863 -lock_arg: 0x9d1edebedf8f026c0d597c4c5cd3f45dec1f7557 -lockScript: - codeHash: 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8 - hashType: type - args: 0x9d1edebedf8f026c0d597c4c5cd3f45dec1f7557 - -- "#": 3 -address: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq0xt7prh3dy3gu9z45svp89q0d6f6c46cg9dp9mn -privkey: 0xf4a1fc19468b51ba9d1f0f5441fa3f4d91e625b2af105e1e37cc54bf9b19c0a1 -pubkey: 0x02e72cbdff20422a3886ec667a138a59478d93da072173be4344c55582acdce67c -lock_arg: 0xe65f823bc5a48a38515690604e503dba4eb15d61 -lockScript: - codeHash: 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8 - hashType: type - args: 0xe65f823bc5a48a38515690604e503dba4eb15d61 -# More accounts... -``` - -```mdx-code-block - - -``` - -:::note -To deposit or check balances on Devnet, ensure that you have started the `offckb node`. This step is not required for Testnet operations. -::: - -#### Deposit Funds - -Occasionally, you may prefer to use your personal CKB account rather than the pre-funded accounts provided by `offckb`. To deposit CKB into your own account using `offckb`, use the command below. Replace `` with your personal CKB address and `` with the specific amount you wish to deposit, expressed in shannons: -:::tip CKB vs. Shannons -1 CKByte = 100,000,000 Shannons -::: - -```mdx-code-block - - -``` - -```bash -offckb deposit --network devnet -``` - -```mdx-code-block - - -``` - -```bash -tx hash: 0xe895970e9c75a5c4703c38a4e37b000895e7690552ba67ef82ae92109d7322fd -``` - -```mdx-code-block - - -``` - -#### Check Balance - -To check the balance of a specific account, use the following command. Replace `` with the address of the account you want to check, and `` with the appropriate network depending on which one you are using: - -```mdx-code-block - - -``` - -```bash -offckb balance --network -``` - -```mdx-code-block - - -``` - -```bash -Balance: 42000000 CKB -``` - -```mdx-code-block - - -``` diff --git a/website/docs/sdk-and-devtool/offckb.mdx b/website/docs/sdk-and-devtool/offckb.mdx new file mode 100644 index 000000000..bcf5bea6b --- /dev/null +++ b/website/docs/sdk-and-devtool/offckb.mdx @@ -0,0 +1,505 @@ +--- +id: offckb +title: OffCKB +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import Tooltip from "@components/Tooltip"; + +# OffCKB + +[offckb](https://github.com/ckb-devrel/offckb) is a an all-in-one CLI tool that provides a local CKB development environment. + +- Simplifies development with one-line command to start the devnet and create projects from boilerplate +- Comes with 20 pre-funded accounts and multiple minimal dApp templates for quick project setup +- Embeds common Scripts in the genesis block, such as Omnilock, xUDT, and Spore +- Provides a complete workflow from Script building and deployment to frontend integration for devnet +- Includes tools like ckb-debugger, molecule, and ckb-cli +- Features a REPL mode for quick Script testing +- Offers configurable settings via a JSON file +- Is built on and leverages CKB's JavaScript SDK, CCC, in the development framework + +This guide will walk you through leveraging OffCKB to kickstart your first CKB project. The version used here is [`v0.3.0`](https://github.com/ckb-devrel/offckb/releases/tag/v0.3.0) or later. + +## Install + +```bash +npm install -g @offckb/cli +``` + +:::tip + +We recommend using [LTS](https://nodejs.org/en/download/package-manager) version of Node to run `offckb`. + +::: + +Once installed, you can view available commands by running `offckb --help`: + +``` +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 + +``` + +:::tip + +Use `offckb [command] -h` to see detailed help for a specific sub command and its options. + +::: + +## Get started + +### Run CKB + +Start a local blockchain with the default CKB version: + +``` +offckb node +``` + +Or, specify a CKB version: + +``` +offckb node 0.117.0 +``` + +Or, set a default CKB version: + +``` +offckb config set ckb-version 0.117.0 +offckb node +``` + +Once the Devnet is running, a RPC server will be available at `http://localhost:8114`. + +An optional RPC proxy server runs at `http://localhost:9000`, forwarding requests to the RPC server. A proxy RPC server is for recording requests and automatically dumping failed transactions for later debugging. + +The proxy server is optional. You can skip it by running: + +``` +offckb node --no-proxy +``` + +Alternatively, start the proxy server in a standalone terminal to better monitor the logs: + +``` +offckb proxy-rpc --ckb-rpc --port 9000 --network devnet +``` + +### Tweak Devnet Config + +OffCKB provides a default configuration for the Devnet, which you can tweak as follows: + +First, start your default CKB Devnet and locate the folder. + +```bash +offckb node +# Once started, press Ctrl+C to stop the node +# Get the config +offckb config list +``` + +Result: + +```json +{ + "devnet": { + "rpcUrl": "", + "configPath": "~/Library/Application Support/offckb-nodejs/devnet", + "dataPath": "~/Library/Application Support/offckb-nodejs/devnet/data" + } +} +``` + +Pay attention to the `devnet.configPath` and `devnet.dataPath`. They are the directories for configuration and chain data storage. + +1. Navigate to `devnet.configPath`, which contains the configuration files for the local blockchain. + +```bash +cd +``` + +Modify the config files as needed to customize your Devnet. For guidance, see [Custom Devnet Setup](https://docs.nervos.org/docs/node/run-devnet-node#custom-devnet-setup) and [Configure CKB](https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md) for a detailed explanation. + +1. Once modified, clear the existing chain data in `devnet.dataPath`. + +``` +rm -rf +``` + +1. Restart the chain with new configurations by running `offckb node`. + +Now your customized Devnet is ready to go. + +### Create a Full-Stack Project + +You can create a new project from predefined boilerplates with the following command: + +``` +offckb create +``` + +The fullstack boilerplate project is a monorepo that contains a script and a frontend project. + +### Start the Frontend + +To start the frontend, navigate to the frontend folder and run: + +``` +cd frontend && npm i & npm run dev +``` + +![image](https://hackmd.io/_uploads/Hkavbybzkg.png) + +The boilerplate supports different CKB networks. Check the [README.md](https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/remix-vite-template/readme.md) in the project for details. + +### Create a Script-Only Project + +You can create a new Script project without a frontend, which is useful when you only want to develop smart contracts for CKB. + +``` +offckb create --script +``` + +:::Note + +Make sure Rust/Cargo/Cargo-generate/Clang 16+ is installed in your environment, since OffCKB relies on [ckb-script-template](https://github.com/cryptape/ckb-script-templates) to handle the core process. + +::: + +### Build and Deploy a Script + +To build the Script, navigate to the root of the project and run: + +``` +make build +``` + +To deploy, go to the frontend folder where the default `offckb.config.ts` is located and run: + +``` +cd frontend && offckb deploy --network +``` + +Or specific the path to `offckb.config.ts` for deploy command to locate: + +``` +offckb deploy --network --config +``` + +Pass `--type-id` to make Scripts upgradable. This is optional: + +``` +cd frontend && offckb deploy --type-id --network +``` + +Once deployed, check the Scripts with following command: + +``` +offckb my-scripts --network +``` + +The deployed Scripts will also be listed in the `frontend/offckb/my-scripts` folder in your frontend project. Also, `offckb.config.ts` will contain the integration details to import and utilize your Scripts in the frontend dApp. + +### Use Deployed Scripts + +Once deployed, use the Scripts as follows in your frontend: + +``` +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, +}; + +``` + +### Debug a Transaction + +Failed transactions will be dumped and recorded by the proxy RPC server for later debugging. + +To debug a transaction by its transaction hash, run the following command: + +``` +offckb debug +``` + +It will verify all the Scripts in the transaction and print the details in the terminal: + +``` +offckb debug --tx-hash 0x64c936ee78107450d49e57b7453dce9031ce68b056b2f1cdad5c2218ab7232ad +Dump transaction successfully + +****************************** +****** Input[0].Lock ****** + +hello, this is new add! +Hashed 1148 bytes in sighash_all +sighash_all = 5d9b2340738ee28729fc74eba35e6ef969878354fe556bd89d5b6f62642f6e50 +event = {"pubkey":"45c41f21e1cf715fa6d9ca20b8e002a574db7bb49e96ee89834c66dac5446b7a","tags":[["ckb_sighash_all","5d9b2340738ee28729fc74eba35e6ef969878354fe556bd89d5b6f62642f6e50"]],"created_at":1725339769,"kind":23334,"content":"Signing a CKB transaction\\n\\nIMPORTANT: Please verify the integrity and authenticity of connected Nostr client before signing this message\\n","id":"90af298075ac878901282e23ce35b24e584b7727bc545e149fc259875a23a7aa","sig":"b505e7d5b643d2e6b1f0e5581221bbfe3c37f17534715e51eecf5ff97a2e1b828a3d767eb712555c78a8736e9085b4960458014fa171d5d169a1b267b186d2f3"} +verify_signature costs 3654 k cycles +Run result: 0 +Total cycles consumed: 4013717(3.8M) +Transfer cycles: 44947(43.9K), running cycles: 3968770(3.8M) + +****************************** +****** Output[0].Type ****** + +verify_signature costs 3654 k cycles +Run result: 0 +Total cycles consumed: 3916670(3.7M) +Transfer cycles: 43162(42.2K), running cycles: 3873508(3.7M) + +``` + +To debug a single Cell Script in a transaction, use the following command: + +``` +offckb debug --single-script +``` + +The `single-cell-script-option` format is `[].`, eg: `"input[0].lock"` + +- `cell-type` can be `input` or `output`, referring to the Cell type +- `cell-index` is the index of the Cell in the transaction +- `script-type` can be `lock` or `type` referring to the Script type + +Or, you can replace the Script with a binary file in a single Cell Script debug session: + +``` +offckb debug --single-script --bin +``` + +All the debug utils are provided by [ckb-debugger](https://github.com/nervosnetwork/ckb-standalone-debugger/tree/develop/ckb-debugger). + +### Generate Molecule Bindings + +[Molecule](https://github.com/nervosnetwork/molecule) is the official [Serialization/Deserialization](https://docs.nervos.org/docs/serialization/serialization-molecule-in-ckb) system for CKB Scripts. + +Define your data structure in `.mol` file (schema), and generate the bindings for different programming languages used in your project. + +``` +offckb mol --schema --output --lang +``` + +Supported languages (`lang`): `ts`, `js`, `c`, `rs`, and `go`. + +For multiple `.mol` files, use a folder as the input and specify an output folder: + +``` +offckb mol --schema --output-folder --lang +``` + +## REPL Mode + +OffCKB packs a custom Node.js REPL with built-in variables and functions to help you develop CKB in the terminal with minimized effort. This is most suitable for simple Script testing tasks when long code is not desirable. + +### Start the OffCKB REPL + +``` +offckb repl --network + +Welcome to OffCKB REPL! +[[ Default Network: devnet, enableProxyRPC: false ]] +Type 'help()' to learn how to use. +OffCKB > + +``` + +Type `help()` to learn about the built-in variables and functions: + +``` +OffCKB > help() + +OffCKB Repl, a Nodejs REPL with CKB bundles. + +Global Variables to use: + - ccc, cccA, imported from CKB Javascript SDK CCC + - client, a CCC client instance bundle with current network + - Client, a Wrap of CCC client class, you can build new client with + const myClient = Client.new('devnet' | 'testnet' | 'mainnet'); + // or + const myClient = Client.fromUrl('', 'devnet' | 'testnet' | 'mainnet'); + - accounts, test accounts array from OffCKB + - networks, network information configs + - help, print this help message + +``` + +### Build a CKB Transaction in REPL + +``` +OffCKB > let amountInCKB = ccc.fixedPointFrom(63); +OffCKB > let tx = ccc.Transaction.from({ +... outputs: [ +... { +... capacity: ccc.fixedPointFrom(amountInCKB), +... lock: accounts[0].lockScript, +... }, +... ], +... }); +OffCKB > let signer = new ccc.SignerCkbPrivateKey(client, accounts[0].privkey); +OffCKB > await tx.completeInputsByCapacity(signer); +2 +OffCKB > await tx.completeFeeBy(signer, 1000); +[ 0, true ] +OffCKB > await mySigner.sendTransaction(tx) +'0x50fbfa8c47907d6842a325e85e48d5da6917e16ca7e2253ec3bd5bcdf8da99ce' + +``` + +### Check Balance in REPL + +``` +OffCKB > let myClient = Client.fromUrl(networks.testnet.rpc_url, 'testnet'); +OffCKB > await myClient.getBalanceSingle(accounts[0].lockScript); +60838485293944n +OffCKB > +``` + +## Configure Settings + +OffCKB settings are saved in a JSON file, which you can edit to update your preferences. + +### List All Settings + +To view all available options and the JSON file path, run: + +``` +offckb config list +``` + +### Set CKB Version + +``` +offckb config get ckb-version +> 0.113.0 +offckb config set ckb-version 0.117.0 +offckb config get ckb-version +> 0.117.0 +``` + +### Set Network Proxy + +``` +offckb config set proxy +> save new settings +offckb config get proxy +> +offckb config rm proxy +> save new settings +offckb config get proxy +> No Proxy. +``` + +## Pre-Funded Accounts + +OffCKB comes with 20 pre-funded accounts, where each one has `42_000_000_00000000` capacity in the genesis block. + +:::note + +These accounts are for development only, do **NOT** send real assets into any of them. + +::: + +Run `offckb accounts` to print the details of these accounts: + +```bash +Print account list, each account is funded with 42_000_000_00000000 capacity in the devnet genesis block. + +- "#": 0 +address: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqvwg2cen8extgq8s5puft8vf40px3f599cytcyd8 +privkey: 0x6109170b275a09ad54877b82f7d9930f88cab5717d484fb4741ae9d1dd078cd6 +pubkey: 0x02025fa7b61b2365aa459807b84df065f1949d58c0ae590ff22dd2595157bffefa +lock_arg: 0x8e42b1999f265a0078503c4acec4d5e134534297 +lockScript: + codeHash: 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8 + hashType: type + args: 0x8e42b1999f265a0078503c4acec4d5e134534297 + +- "#": 1 +address: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqt435c3epyrupszm7khk6weq5lrlyt52lg48ucew +privkey: 0x9f315d5a9618a39fdc487c7a67a8581d40b045bd7a42d83648ca80ef3b2cb4a1 +pubkey: 0x026efa0579f09cc7c1129b78544f70098c90b2ab155c10746316f945829c034a2d +lock_arg: 0x758d311c8483e0602dfad7b69d9053e3f917457d +lockScript: + codeHash: 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8 + hashType: type + args: 0x758d311c8483e0602dfad7b69d9053e3f917457d +.... +``` + +## Built-In Scripts + +OffCKB embeds common Scripts in the genesis block of the local chain. You can use it without manual deployment. + +Here we list the built-in Scripts source information: + +- [xUDT](<[https://github.com/nervosnetwork/rfcs/pull/428](https://github.com/nervosnetwork/rfcs/pull/428)>) + - commit id: 410b16c +- [Omnilock](<[https://github.com/cryptape/omnilock](https://github.com/cryptape/omnilock)>) + - commit id: cd764d7 +- [AnyoneCanPay](<[https://github.com/cryptape/anyone-can-pay](https://github.com/cryptape/anyone-can-pay)>) + - commit id: b845b3b +- [AlwaysSuccess](<[https://github.com/nervosnetwork/ckb-production-scripts/blob/master/c/always_success.c](https://github.com/nervosnetwork/ckb-production-scripts/blob/master/c/always_success.c)>) + - commit id: 410b16c +- [Spore](<[https://github.com/sporeprotocol/spore-contract](https://github.com/sporeprotocol/spore-contract)>) + - version: 0.2.2-beta.1 + +For all the genesis built-in Scripts information, use `offckb system-scripts` command: + +``` +offckb system-scripts --network devnet +``` + +Or export the Scripts info to a Lumos JSON file: + +``` +offckb system-scripts --export-style lumos +``` + +Or print the Scripts info in the CCC format: + +``` +offckb system-scripts --export-style ccc +``` + +## About CCC + +OffCKB uses [CCC](https://github.com/ckb-devrel/ccc) (CKB Javascript SDK) as the development framework for CKB dApp template projects and is itself built on CCC. For documentation, visit: + +- CCC on Nervos Docs: [docs.nervos.org/docs/sdk-and-devtool/ccc](https://docs.nervos.org/docs/sdk-and-devtool/ccc) +- CCC Documentation: [docs.ckbccc.com](https://docs.ckbccc.com/) + +We hope this guide can help you get started with your CKB development journey! If you encounter any problems, please don't hesitate to reach out via [@CKBDev](https://x.com/CKBdev) on X/Twitter. diff --git a/website/sidebars.js b/website/sidebars.js index 99599865a..6d0bd8025 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -24,7 +24,8 @@ export default { "sdk-and-devtool/java", "sdk-and-devtool/ccc", "sdk-and-devtool/lumos", - "sdk-and-devtool/cli-tools", + "sdk-and-devtool/ckb-cli", + "sdk-and-devtool/offckb", "sdk-and-devtool/devtool", ], }, diff --git a/website/src/components/TutorialHeader/index.tsx b/website/src/components/TutorialHeader/index.tsx index c0506ba86..33325ef73 100644 --- a/website/src/components/TutorialHeader/index.tsx +++ b/website/src/components/TutorialHeader/index.tsx @@ -30,7 +30,7 @@ const DAPP_HEADER: JSX.Element[] = [ target="_blank" rel="noopener noreferrer" > - OffCKB (≥v0.3.0-rc2) + OffCKB (≥v0.3.0) ,
diff --git a/website/static/img/quick-start/next-js-dapp.jpg b/website/static/img/quick-start/next-js-dapp.jpg deleted file mode 100644 index 66e0c2b5d..000000000 Binary files a/website/static/img/quick-start/next-js-dapp.jpg and /dev/null differ diff --git a/website/static/img/quick-start/remix-vite-dapp.jpg b/website/static/img/quick-start/remix-vite-dapp.jpg deleted file mode 100644 index f628f3db0..000000000 Binary files a/website/static/img/quick-start/remix-vite-dapp.jpg and /dev/null differ diff --git a/website/static/img/quick-start/remix-vite-dapp.png b/website/static/img/quick-start/remix-vite-dapp.png new file mode 100644 index 000000000..ee206b59e Binary files /dev/null and b/website/static/img/quick-start/remix-vite-dapp.png differ