@offckb/cli 0.4.9-canary-2b6b3af.0 → 0.4.9-canary-807f2ef.0
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.
- package/README.md +40 -17
- package/build/index.js +1096 -275
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ CKB local development network for your first try.
|
|
|
18
18
|
|
|
19
19
|
There are BREAKING CHANGES between v0.3.x and v0.4.x, make sure to read the [migration guide](/docs/migration.md) before upgrading.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
---
|
|
22
22
|
|
|
23
23
|
- [OffCKB](#offckb)
|
|
24
24
|
- [Install](#install)
|
|
@@ -92,7 +92,7 @@ _Use `offckb [command] -h` to learn more about a specific command._
|
|
|
92
92
|
## Get started
|
|
93
93
|
|
|
94
94
|
### 1. Run a Local CKB Devnet {#running-ckb}
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
Start a local blockchain with one command:
|
|
97
97
|
|
|
98
98
|
```sh
|
|
@@ -151,7 +151,7 @@ offckb node --daemon --json
|
|
|
151
151
|
Each log line is a single JSON object:
|
|
152
152
|
|
|
153
153
|
```json
|
|
154
|
-
{"level":"info","message":"Launching CKB devnet Node...","timestamp":"2026-07-07T07:10:00.000Z"}
|
|
154
|
+
{ "level": "info", "message": "Launching CKB devnet Node...", "timestamp": "2026-07-07T07:10:00.000Z" }
|
|
155
155
|
```
|
|
156
156
|
|
|
157
157
|
**RPC & Proxy RPC**
|
|
@@ -163,11 +163,12 @@ When the Devnet starts:
|
|
|
163
163
|
|
|
164
164
|
The proxy RPC server forwards all requests to the RPC server and record every requests while automatically dumping failed transactions for easier debugging.
|
|
165
165
|
|
|
166
|
-
You can also start a proxy RPC server for public networks:
|
|
166
|
+
You can also start a proxy RPC server for public networks:
|
|
167
167
|
|
|
168
168
|
```sh
|
|
169
169
|
offckb node --network <testnet or mainnet>
|
|
170
170
|
```
|
|
171
|
+
|
|
171
172
|
Using a proxy RPC server for Testnet/Mainnet is especially helpful for debugging transactions, since failed transactions are dumped automatically.
|
|
172
173
|
|
|
173
174
|
**Watch Network with TUI**
|
|
@@ -175,11 +176,13 @@ Using a proxy RPC server for Testnet/Mainnet is especially helpful for debugging
|
|
|
175
176
|
Once you start the CKB Node, you can use `offckb status --network devnet/testnet/mainnet` to start a CKB-TUI interface to monitor the CKB network from your node.
|
|
176
177
|
|
|
177
178
|
### 2. Create a New Contract Project {#create-project}
|
|
178
|
-
|
|
179
|
+
|
|
179
180
|
Generate a ready-to-use smart-contract project in JS/TS using templates:
|
|
181
|
+
|
|
180
182
|
```sh
|
|
181
183
|
offckb create <your-project-name> -c <your-contract-name>
|
|
182
184
|
```
|
|
185
|
+
|
|
183
186
|
- The `-c` option is optional, if not provided, the contract name defaults to `hello-world`.
|
|
184
187
|
|
|
185
188
|
**Note for Windows Users:**
|
|
@@ -210,10 +213,11 @@ To run mock tests in the generated project, you need to manually install `ckb-de
|
|
|
210
213
|
After completing these steps, `npm run test` should pass without mock test failures.
|
|
211
214
|
|
|
212
215
|
### 3. Deploy Your Contract {#deploy-contract}
|
|
213
|
-
|
|
216
|
+
|
|
214
217
|
```sh
|
|
215
218
|
offckb deploy --network <devnet/testnet> --target <path-to-your-contract-binary-file-or-folder> --output <output-folder-path>
|
|
216
219
|
```
|
|
220
|
+
|
|
217
221
|
- Deployment info is written to the `output-folder-path` you specify.
|
|
218
222
|
|
|
219
223
|
**Upgradable Scripts with `--type-id`**
|
|
@@ -224,14 +228,14 @@ offckb deploy --type-id --network <devnet/testnet>
|
|
|
224
228
|
```
|
|
225
229
|
|
|
226
230
|
- **Important**: Upgrades are keyed by the contract‘s artifact name.
|
|
227
|
-
|
|
228
|
-
|
|
231
|
+
- If you plan to upgrade with `--type-id`, do not rename your contract artifact (e.g. keep `hello-world.bc`).
|
|
232
|
+
- 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.
|
|
229
233
|
|
|
230
234
|
### 4. Debug Your Contract {#debug-contract}
|
|
231
|
-
|
|
232
|
-
When you interact with the CKB Devnet through the Proxy RPC server (localhost:28114), any failed transactions are automatically dumped and recorded for debugging.
|
|
233
|
-
|
|
234
|
-
**Debug a Transaction:**
|
|
235
|
+
|
|
236
|
+
When you interact with the CKB Devnet through the Proxy RPC server (localhost:28114), any failed transactions are automatically dumped and recorded for debugging.
|
|
237
|
+
|
|
238
|
+
**Debug a Transaction:**
|
|
235
239
|
|
|
236
240
|
```sh
|
|
237
241
|
offckb debug --tx-hash <transaction-hash> --network <devnet/testnet>
|
|
@@ -283,9 +287,9 @@ offckb debug --tx-hash <tx-hash> --single-script input[0].lock
|
|
|
283
287
|
```
|
|
284
288
|
|
|
285
289
|
All debug utilities are powered by [ckb-debugger](https://github.com/nervosnetwork/ckb-standalone-debugger/tree/develop/ckb-debugger).
|
|
286
|
-
|
|
290
|
+
|
|
287
291
|
### 5. Explore Built-in Scripts {#explore-scripts}
|
|
288
|
-
|
|
292
|
+
|
|
289
293
|
Print all the predefined Scripts for the local blockchain:
|
|
290
294
|
|
|
291
295
|
```sh
|
|
@@ -311,9 +315,9 @@ offckb system-scripts --export-style ccc
|
|
|
311
315
|
```sh
|
|
312
316
|
offckb system-scripts --output <output-file-path>
|
|
313
317
|
```
|
|
314
|
-
|
|
318
|
+
|
|
315
319
|
### 6. Tweak Devnet Config {#tweak-devnet-config}
|
|
316
|
-
|
|
320
|
+
|
|
317
321
|
By default, OffCKB use a fixed Devnet config. You can customize it, for example by modifying the default log level (`warn,ckb-script=debug`).
|
|
318
322
|
|
|
319
323
|
1. Open the interactive Devnet config editor:
|
|
@@ -370,6 +374,26 @@ Pay attention to the `devnet.configPath` and `devnet.dataPath`.
|
|
|
370
374
|
2. After modifications, run `offckb clean -d` to remove the chain data if needed while keeping the updated config files.
|
|
371
375
|
3. Restart local blockchain by running `offckb node`
|
|
372
376
|
|
|
377
|
+
### 7. Fork Mainnet/Testnet Into Your Devnet {#fork-devnet}
|
|
378
|
+
|
|
379
|
+
You can fork an existing Mainnet/Testnet data directory into your local devnet, so it keeps the real on-chain state (deployed contracts, cells) while mining locally with Dummy PoW. This implements the same flow as [Devnet From Existing Data](https://docs.nervos.org/docs/node/devnet-from-existing-data).
|
|
380
|
+
|
|
381
|
+
```sh
|
|
382
|
+
offckb devnet fork --from /path/to/ckb-data
|
|
383
|
+
offckb node
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
- `--from` points at the directory the source node runs with (`-C`), which must contain `data/db`. Stop the source node first.
|
|
387
|
+
- The source chain is auto-detected from the source `ckb.toml`; pass `--source mainnet|testnet` when it cannot be detected, and `--spec-file <path>` to use a local chain spec (e.g. offline).
|
|
388
|
+
- The command copies the chain `data/` (your original data is never modified), imports the matching chain spec, patches it for local mining (Dummy PoW, `cellbase_maturity = 0`), and verifies the genesis hash.
|
|
389
|
+
- The first `offckb node` run automatically boots with `--skip-spec-check --overwrite-spec`; later runs are normal.
|
|
390
|
+
- Forking replaces the current devnet; use `--force` to replace an existing devnet/fork, or `offckb clean` to reset back to a pure devnet.
|
|
391
|
+
|
|
392
|
+
On a forked devnet, `offckb system-scripts`, transfers, deploys and `offckb debug --tx-hash <hash>` work against the real source-chain state, e.g. debugging a failed mainnet transaction fully locally.
|
|
393
|
+
|
|
394
|
+
> [!CAUTION]
|
|
395
|
+
> CKB transactions carry no chain id, so a transaction built on a mainnet fork that spends copied mainnet cells is also valid on mainnet (CKB provides no replay protection). offckb's own flows only use dev keys and fork-mined cells, which cannot replay. Never sign transactions with real mainnet keys against a fork unless you intend to broadcast them yourself.
|
|
396
|
+
|
|
373
397
|
## Config Setting
|
|
374
398
|
|
|
375
399
|
### List All Settings
|
|
@@ -455,4 +479,3 @@ npm install -g @offckb/cli
|
|
|
455
479
|
## Contributing
|
|
456
480
|
|
|
457
481
|
check [development doc](/docs/develop.md)
|
|
458
|
-
|