@offckb/cli 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +107 -107
  2. package/build/index.js +3 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -12,6 +12,7 @@ CKB local development network for your first try.
12
12
  - Pre-funded test accounts
13
13
  - Built-in scripts like [CKB-JS-VM](https://github.com/nervosnetwork/ckb-js-vm) and [Spore-contract](https://github.com/sporeprotocol/spore-contract)
14
14
  - Create boilerplate to build CKB Smart Contract in Typescript
15
+ - Proxy RPC that automatically dumps failed transactions for easier debugging
15
16
 
16
17
  **Migrate from v0.3.x to v0.4.x:**
17
18
 
@@ -23,12 +24,12 @@ There are BREAKING CHANGES between v0.3.x and v0.4.x, make sure to read the [mig
23
24
  - [Install](#install)
24
25
  - [Usage](#usage)
25
26
  - [Get started](#get-started)
26
- - [Running CKB](#running-ckb)
27
- - [List scripts info](#list-scripts-info)
27
+ - [Run a Local CKB Devnet](#running-ckb)
28
+ - [Create a CKB Smart Contract Project](#create-project)
29
+ - [Deploy a CKB Smart Contract](#deploy-contract)
30
+ - [Debug a CKB Smart Contract](#debug-contract)
31
+ - [Explore built-in Scripts info](#explore-scripts)
28
32
  - [Tweak Devnet Config](#tweak-devnet-config)
29
- - [Create a CKB Smart Contract Project](#create-a-ckb-smart-contract-project)
30
- - [Deploy a CKB Smart Contract](#deploy-a-ckb-smart-contract)
31
- - [Debug a transaction](#debug-a-transaction)
32
33
  - [Config Setting](#config-setting)
33
34
  - [List All Settings](#list-all-settings)
34
35
  - [Set CKB version](#set-ckb-version)
@@ -86,137 +87,79 @@ _Use `offckb [command] -h` to learn more about a specific command._
86
87
 
87
88
  ## Get started
88
89
 
89
- ### Running CKB
90
-
91
- Start a local blockchain with the default CKB version:
90
+ ### 1. Run a Local CKB Devnet {#running-ckb}
91
+
92
+ Start a local blockchain with one command:
92
93
 
93
94
  ```sh
94
95
  offckb node
95
96
  ```
96
97
 
97
- Or specify a CKB version:
98
+ Specify a CKB version:
98
99
 
99
100
  ```sh
100
101
  offckb node 0.201.0
101
102
  ```
102
103
 
103
- Or set the default CKB version:
104
+ Or set a default version globally:
104
105
 
105
106
  ```sh
106
107
  offckb config set ckb-version 0.201.0
107
108
  offckb node
108
109
  ```
110
+ **RPC & Proxy RPC**
109
111
 
110
- Once you start the devnet, there is a RPC server running at `http://127.0.0.1:8114`. There is also a RPC proxy server running at `http://127.0.0.1:28114` which will proxy all the requests to the RPC server. The meaning of using a proxy RPC server is to record request and automatically dump failed transactions so you can debug them easily later.
111
-
112
- In the same way, you can also start proxy RPC server for `testnet` and `mainnet` by running:
113
-
114
- ```sh
115
- offckb node --network <testnet or mainnet>
116
- ```
117
-
118
- Using a local proxy RPC server for public testnet/mainnet is also very helpful for debugging the requests and the automatically recorded dump transactions.
119
-
120
- ### List scripts info
121
-
122
- Print all the predefined scripts for the local blockchain:
123
-
124
- ```sh
125
- offckb system-scripts
126
- ```
127
-
128
- Or print the scripts info to a lumos JSON file:
129
-
130
- ```sh
131
- offckb system-scripts --export-style lumos
132
- ```
112
+ When the Devnet starts:
133
113
 
134
- Or print the scripts info in a CCC style:
114
+ - The RPC server runs at [http://127.0.0.1:8114](http://127.0.0.1:8114/)
115
+ - The proxy RPC server runs at [http://127.0.0.1:28114](http://127.0.0.1:28114/)
135
116
 
136
- ```sh
137
- offckb system-scripts --export-style ccc
138
- ```
117
+ The proxy RPC server forwards all requests to the RPC server and record every requests while automatically dumping failed transactions for easier debugging.
139
118
 
140
- You can also export the scripts info to a JSON file:
119
+ You can also start a proxy RPC server for public networks:
141
120
 
142
121
  ```sh
143
- offckb system-scripts --output <output-file-path>
122
+ offckb node --network <testnet or mainnet>
144
123
  ```
124
+ Using a proxy RPC server for Testnet/Mainnet is especially helpful for debugging transactions, since failed transactions are dumped automatically.
145
125
 
146
- ### Tweak Devnet Config
147
-
148
- By default, offckb use a fixed devnet config for the local blockchain. You can tweak the config to customize the devnet, for example, modify the default log level for the devnet CKB Node `warn,ckb-script=debug`.
149
-
150
- To tweak the devnet config, follow the steps below:
151
-
152
- 1. Locate your devnet config folder by running:
153
-
154
- ```sh
155
- offckb config list
156
- ```
157
-
158
- Result:
159
-
160
- ```json
161
- {
162
- "devnet": {
163
- "rpcUrl": "http://127.0.0.1:8114",
164
- "configPath": "~/Library/Application Support/offckb-nodejs/devnet",
165
- "dataPath": "~/Library/Application Support/offckb-nodejs/devnet/data"
166
- }
167
- }
168
- ```
169
-
170
- Pay attention to the `devnet.configPath` and `devnet.dataPath`. They are the ones we need.
171
- 2. `cd` into the `devnet.configPath`, this is the config folder for the local blockchain. Modify the config in the folder to better customize the devnet. For customization, 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 better explanation of the config files.
172
- 3. After modifications, remove everything in the `devnet.dataPath` folder. This will clean the chain data.
173
- 4. Restart local blockchain by running `offckb node`
174
-
175
- Done.
176
-
177
- ### Create a CKB Smart Contract Project
178
-
179
- You can create a new CKB Smart Contract project in Typescript from our boilerplate.
180
-
126
+ ### 2. Create a New Contract Project {#create-project}
127
+
128
+ Generate a ready-to-use project in JS/TS using templates:
181
129
  ```sh
182
130
  offckb create <your-project-name> -c <your-contract-name>
183
131
  ```
132
+ - The `-c` option is optional, if not provided, the contract name defaults to `hello-world`.
184
133
 
185
- The `-c` option is optional, if you don't provide it, the contract name will be `hello-world`.
186
-
187
- After create the project, you can follow the instructions on build, deploy and test the contract in README.md of the project.
188
-
189
- The project includes both `mock` test and `devnet` test. For developing frontend interacting with the blockchain, you can refer to the `devnet` test and see how it works.
190
-
191
- ### Deploy a CKB Smart Contract
192
-
193
- To deploy the script, use `offckb deploy` command:
194
-
134
+ ### 3. Deploy Your Contract {#deploy-contract}
135
+
195
136
  ```sh
196
137
  offckb deploy --network <devnet/testnet> --target <path-to-your-contract-binary-file-or-folder> --output <output-folder-path>
197
138
  ```
139
+ - Deployment info is written to the `output-folder-path` you specify.
198
140
 
199
- Pass `--type-id` option if you want Scripts to be upgradable
141
+ **Upgradable Scripts with `--type-id`**
142
+ Pass the `--type-id` option if you want your Scripts to be upgradable:
200
143
 
201
144
  ```sh
202
145
  offckb deploy --type-id --network <devnet/testnet>
203
146
  ```
204
147
 
205
- Your deployed scripts info will be be listed in the `output-folder-path` which you defined in the command.
206
-
207
- Note that upgrades are keyed by the contract‘s artifact name. If you plan to upgrade with `--type-id`, do not rename your contract artifact (e.g. keep `hello-world.bc`). Renaming it makes the offckb unable to find the previous Type ID info from the `output-folder-path` and will create a new Type ID.
208
-
209
- ### Debug a transaction
148
+ - **Important**: Upgrades are keyed by the contract‘s artifact name.
149
+ - If you plan to upgrade with `--type-id`, do not rename your contract artifact (e.g. keep `hello-world.bc`).
150
+ - Renaming it makes the offckb unable to find the previous Type ID info from the `output-folder-path` and will create a new Type ID.
210
151
 
211
- If you are interacting the CKB devnet via the proxy RPC server(`localhost:28114`), all the failed transactions will be dumped and recorded so you can debug them later.
212
-
213
- Every time you run a transaction, you can debug it with the transaction hash:
152
+ ### 4. Debug Your Contract {#debug-contract}
153
+
154
+ When you interact with the CKB Devnet through the Proxy RPC server (localhost:28114), any failed transactions are automatically dumped and recorded for debugging.
155
+
156
+ **Debug a Transaction:**
214
157
 
215
158
  ```sh
216
- offckb debug <transaction-hash>
159
+ offckb debug --tx-hash <transaction-hash> --network <devnet/testnet>
217
160
  ```
218
161
 
219
- It will verify all the scripts in the transaction and print the detailed info in the terminal.
162
+ output example:
220
163
 
221
164
  ```sh
222
165
  offckb debug --tx-hash 0x64c936ee78107450d49e57b7453dce9031ce68b056b2f1cdad5c2218ab7232ad
@@ -243,25 +186,81 @@ Total cycles consumed: 3916670(3.7M)
243
186
  Transfer cycles: 43162(42.2K), running cycles: 3873508(3.7M)
244
187
  ```
245
188
 
246
- If you want to debug a single cell script in the transaction, you can use the following command:
189
+ Debug a Single Cell Script:
247
190
 
248
191
  ```sh
249
192
  offckb debug <transaction-hash> --single-script <single-cell-script-option>
250
193
  ```
251
194
 
252
- The `single-cell-script-option` format is `<cell-type>[<cell-index>].<script-type>`, eg: `"input[0].lock"`
195
+ The `single-cell-script-option` format is `<cell-type>[<cell-index>].<script-type>`
196
+
197
+ - `cell-type` → `input` or `output`
198
+ - `cell-index` → index of the Cell in the transaction
199
+ - `script-type` → `lock` or `type`
200
+
201
+ Example:
202
+
203
+ ```sh
204
+ offckb debug --tx-hash <tx-hash> --single-script input[0].lock
205
+ ```
206
+
207
+ All debug utilities are powered by [ckb-debugger](https://github.com/nervosnetwork/ckb-standalone-debugger/tree/develop/ckb-debugger).
208
+
209
+ ### 5. Explore Built-in Scripts {#explore-scripts}
210
+
211
+ Print all the predefined Scripts for the local blockchain:
212
+
213
+ ```sh
214
+ offckb system-scripts --list
215
+ ```
216
+
217
+ Export options:
218
+
219
+ - Lumos format
220
+
221
+ ```sh
222
+ offckb system-scripts --export-style lumos
223
+ ```
224
+
225
+ - CCC format:
253
226
 
254
- - `cell-type` could be `input` or `output`, refers to the cell type
255
- - `cell-index` is the index of the cell in the transaction
256
- - `script-type` could be `lock` or `type`, refers to the script type
227
+ ```sh
228
+ offckb system-scripts --export-style ccc
229
+ ```
257
230
 
258
- Or you can replace the script with a binary file in your single cell script debug session:
231
+ - Save to a JSON file:
259
232
 
260
233
  ```sh
261
- offckb debug <transaction-hash> --single-script <single-cell-script-option> --bin <path/to/binary/file>
234
+ offckb system-scripts --output <output-file-path>
235
+ ```
236
+
237
+ ### 6. Tweak Devnet Config {#tweak-devnet-config}
238
+
239
+ By default, OffCKB use a fixed Devnet config. You can customize it, for example by modifying the default log level (`warn,ckb-script=debug`).
240
+
241
+ 1. Locate your Devnet config folder:
242
+
243
+ ```sh
244
+ offckb config list
245
+ ```
246
+
247
+ Example result:
248
+
249
+ ```json
250
+ {
251
+ "devnet": {
252
+ "rpcUrl": "http://127.0.0.1:8114",
253
+ "configPath": "~/Library/Application Support/offckb-nodejs/devnet",
254
+ "dataPath": "~/Library/Application Support/offckb-nodejs/devnet/data"
255
+ }
256
+ }
262
257
  ```
258
+ Pay attention to the `devnet.configPath` and `devnet.dataPath`.
259
+
260
+ 2. `cd` into the `devnet.configPath` . Modify the config files as needed. 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 details.
261
+ 3. After modifications, remove everything in the `devnet.dataPath` folder to reset chain data.
262
+ 4. Restart local blockchain by running `offckb node`
263
263
 
264
- All the debug utils are borrowed from [ckb-debugger](https://github.com/nervosnetwork/ckb-standalone-debugger/tree/develop/ckb-debugger).
265
264
 
266
265
  ## Config Setting
267
266
 
@@ -324,12 +323,13 @@ LOG_LEVEL=debug offckb node
324
323
 
325
324
  ## Accounts
326
325
 
327
- `offckb` comes with 20 accounts, each account is funded with 42_000_000_00000000 capacity in the genesis block.
326
+ OffCKB comes with 20 pre-funded accounts, each initialized with `42_000_000_00000000` capacity in the genesis block.
328
327
 
329
- all the private keys are recorded in the `account/keys` file.
330
- detail informations about each account are recorded in the `account/account.json` file.
328
+ - All private keys are stored in the `account/keys` file.
329
+ - Detailed information for each account is recorded in `account/account.json`.
330
+ - When deploying contracts, the deployment cost are automatically deducted from these pre-funded accounts. This allows you to test deployments without faucets or manual funding.
331
331
 
332
- :warning: **DO NOT SEND REAL ASSETS INTO ALL THESE ACCOUNTS, YOU CAN LOOSE YOUR MONEY** :warning:
332
+ :warning: **DO NOT SEND REAL ASSETS TO THESE ACCOUNTS. THE KEYS ARE PUBLIC, AND YOU MAY LOSE YOUR MONEY** :warning:
333
333
 
334
334
  ## About CCC
335
335
 
package/build/index.js CHANGED
@@ -3381,8 +3381,8 @@ exports.TEMPLATE_CONFIG = {
3381
3381
  dotenv: '^17.2.1',
3382
3382
  },
3383
3383
  devDependencies: {
3384
- 'ckb-testtool': '~1.0.3',
3385
- '@ckb-ccc/core': '~1.5.3', // Pin to version compatible with ckb-testtool
3384
+ 'ckb-testtool': '1.0.3',
3385
+ '@ckb-ccc/core': '1.5.3', // lock to version compatible with ckb-testtool
3386
3386
  esbuild: '~0.25.8',
3387
3387
  jest: '~29.7.0',
3388
3388
  prettier: '^3.5.3',
@@ -129006,7 +129006,7 @@ module.exports = {"version":"3.17.0"};
129006
129006
  /***/ ((module) => {
129007
129007
 
129008
129008
  "use strict";
129009
- module.exports = /*#__PURE__*/JSON.parse('{"rE":"0.4.0","h_":"ckb development network for your first try"}');
129009
+ module.exports = /*#__PURE__*/JSON.parse('{"rE":"0.4.1","h_":"ckb development network for your first try"}');
129010
129010
 
129011
129011
  /***/ })
129012
129012
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "ckb development network for your first try",
5
5
  "author": "CKB EcoFund",
6
6
  "license": "MIT",