@offckb/cli 0.4.8 → 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 +79 -16
- package/build/index.js +2473 -301
- 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)
|
|
@@ -70,6 +70,7 @@ Options:
|
|
|
70
70
|
|
|
71
71
|
Commands:
|
|
72
72
|
node [CKB-Version] Use the CKB to start devnet
|
|
73
|
+
node stop Stop the running CKB devnet daemon
|
|
73
74
|
create [options] [project-name] Create a new CKB Smart Contract project in JavaScript.
|
|
74
75
|
deploy [options] Deploy contracts to different networks, only supports devnet and testnet
|
|
75
76
|
debug [options] Quickly debug transaction with tx-hash
|
|
@@ -81,6 +82,7 @@ Commands:
|
|
|
81
82
|
transfer-all [options] [toAddress] Transfer All CKB tokens to address, only devnet and testnet
|
|
82
83
|
balance [options] [toAddress] Check account balance, only devnet and testnet
|
|
83
84
|
debugger Port of the raw CKB Standalone Debugger
|
|
85
|
+
status [options] Show ckb-tui status interface
|
|
84
86
|
config <action> [item] [value] do a configuration action
|
|
85
87
|
help [command] display help for command
|
|
86
88
|
```
|
|
@@ -90,7 +92,7 @@ _Use `offckb [command] -h` to learn more about a specific command._
|
|
|
90
92
|
## Get started
|
|
91
93
|
|
|
92
94
|
### 1. Run a Local CKB Devnet {#running-ckb}
|
|
93
|
-
|
|
95
|
+
|
|
94
96
|
Start a local blockchain with one command:
|
|
95
97
|
|
|
96
98
|
```sh
|
|
@@ -118,6 +120,40 @@ offckb node --binary-path /path/to/your/ckb/binary
|
|
|
118
120
|
|
|
119
121
|
When using `--binary-path`, it will ignore the specified version and network, and only work for devnet.
|
|
120
122
|
|
|
123
|
+
**Run in Daemon Mode**
|
|
124
|
+
|
|
125
|
+
Start the devnet in the background so your terminal stays free:
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
offckb node --daemon
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The daemon writes its logs and PID to the devnet data folder, for example:
|
|
132
|
+
|
|
133
|
+
- Logs: `~/Library/Application Support/offckb-nodejs/devnet/data/logs/daemon.log`
|
|
134
|
+
- PID file: `~/Library/Application Support/offckb-nodejs/devnet/data/logs/daemon.pid`
|
|
135
|
+
|
|
136
|
+
Stop the daemon later with:
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
offckb node stop
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Agent-Friendly JSON Output**
|
|
143
|
+
|
|
144
|
+
For programmatic consumption or agent integration, add `--json` to any command to emit structured JSON logs:
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
offckb node --json
|
|
148
|
+
offckb node --daemon --json
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Each log line is a single JSON object:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{ "level": "info", "message": "Launching CKB devnet Node...", "timestamp": "2026-07-07T07:10:00.000Z" }
|
|
155
|
+
```
|
|
156
|
+
|
|
121
157
|
**RPC & Proxy RPC**
|
|
122
158
|
|
|
123
159
|
When the Devnet starts:
|
|
@@ -127,19 +163,26 @@ When the Devnet starts:
|
|
|
127
163
|
|
|
128
164
|
The proxy RPC server forwards all requests to the RPC server and record every requests while automatically dumping failed transactions for easier debugging.
|
|
129
165
|
|
|
130
|
-
You can also start a proxy RPC server for public networks:
|
|
166
|
+
You can also start a proxy RPC server for public networks:
|
|
131
167
|
|
|
132
168
|
```sh
|
|
133
169
|
offckb node --network <testnet or mainnet>
|
|
134
170
|
```
|
|
171
|
+
|
|
135
172
|
Using a proxy RPC server for Testnet/Mainnet is especially helpful for debugging transactions, since failed transactions are dumped automatically.
|
|
136
173
|
|
|
174
|
+
**Watch Network with TUI**
|
|
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.
|
|
177
|
+
|
|
137
178
|
### 2. Create a New Contract Project {#create-project}
|
|
138
|
-
|
|
179
|
+
|
|
139
180
|
Generate a ready-to-use smart-contract project in JS/TS using templates:
|
|
181
|
+
|
|
140
182
|
```sh
|
|
141
183
|
offckb create <your-project-name> -c <your-contract-name>
|
|
142
184
|
```
|
|
185
|
+
|
|
143
186
|
- The `-c` option is optional, if not provided, the contract name defaults to `hello-world`.
|
|
144
187
|
|
|
145
188
|
**Note for Windows Users:**
|
|
@@ -170,10 +213,11 @@ To run mock tests in the generated project, you need to manually install `ckb-de
|
|
|
170
213
|
After completing these steps, `npm run test` should pass without mock test failures.
|
|
171
214
|
|
|
172
215
|
### 3. Deploy Your Contract {#deploy-contract}
|
|
173
|
-
|
|
216
|
+
|
|
174
217
|
```sh
|
|
175
218
|
offckb deploy --network <devnet/testnet> --target <path-to-your-contract-binary-file-or-folder> --output <output-folder-path>
|
|
176
219
|
```
|
|
220
|
+
|
|
177
221
|
- Deployment info is written to the `output-folder-path` you specify.
|
|
178
222
|
|
|
179
223
|
**Upgradable Scripts with `--type-id`**
|
|
@@ -184,14 +228,14 @@ offckb deploy --type-id --network <devnet/testnet>
|
|
|
184
228
|
```
|
|
185
229
|
|
|
186
230
|
- **Important**: Upgrades are keyed by the contract‘s artifact name.
|
|
187
|
-
|
|
188
|
-
|
|
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.
|
|
189
233
|
|
|
190
234
|
### 4. Debug Your Contract {#debug-contract}
|
|
191
|
-
|
|
192
|
-
When you interact with the CKB Devnet through the Proxy RPC server (localhost:28114), any failed transactions are automatically dumped and recorded for debugging.
|
|
193
|
-
|
|
194
|
-
**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:**
|
|
195
239
|
|
|
196
240
|
```sh
|
|
197
241
|
offckb debug --tx-hash <transaction-hash> --network <devnet/testnet>
|
|
@@ -243,9 +287,9 @@ offckb debug --tx-hash <tx-hash> --single-script input[0].lock
|
|
|
243
287
|
```
|
|
244
288
|
|
|
245
289
|
All debug utilities are powered by [ckb-debugger](https://github.com/nervosnetwork/ckb-standalone-debugger/tree/develop/ckb-debugger).
|
|
246
|
-
|
|
290
|
+
|
|
247
291
|
### 5. Explore Built-in Scripts {#explore-scripts}
|
|
248
|
-
|
|
292
|
+
|
|
249
293
|
Print all the predefined Scripts for the local blockchain:
|
|
250
294
|
|
|
251
295
|
```sh
|
|
@@ -271,9 +315,9 @@ offckb system-scripts --export-style ccc
|
|
|
271
315
|
```sh
|
|
272
316
|
offckb system-scripts --output <output-file-path>
|
|
273
317
|
```
|
|
274
|
-
|
|
318
|
+
|
|
275
319
|
### 6. Tweak Devnet Config {#tweak-devnet-config}
|
|
276
|
-
|
|
320
|
+
|
|
277
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`).
|
|
278
322
|
|
|
279
323
|
1. Open the interactive Devnet config editor:
|
|
@@ -330,6 +374,26 @@ Pay attention to the `devnet.configPath` and `devnet.dataPath`.
|
|
|
330
374
|
2. After modifications, run `offckb clean -d` to remove the chain data if needed while keeping the updated config files.
|
|
331
375
|
3. Restart local blockchain by running `offckb node`
|
|
332
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
|
+
|
|
333
397
|
## Config Setting
|
|
334
398
|
|
|
335
399
|
### List All Settings
|
|
@@ -415,4 +479,3 @@ npm install -g @offckb/cli
|
|
|
415
479
|
## Contributing
|
|
416
480
|
|
|
417
481
|
check [development doc](/docs/develop.md)
|
|
418
|
-
|