@offckb/cli 0.3.0-canary-34f0d45.0 → 0.3.0-canary-201a756.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 +145 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
**CKB local development network for your first try.**
|
|
10
10
|
|
|
11
11
|
- One-line command to start a devnet
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
12
|
+
- No docker required
|
|
13
|
+
- Pre-funded test accounts
|
|
14
|
+
- Built-in scripts like [Omnilock](https://github.com/cryptape/omnilock) and [Spore-contract](https://github.com/sporeprotocol/spore-contract)
|
|
15
|
+
- Multiple minimal dApp templates to learn and get your hands dirty
|
|
16
16
|
|
|
17
17
|
Start building on CKB blockchain, right now, right away!
|
|
18
18
|
|
|
@@ -23,8 +23,14 @@ Start building on CKB blockchain, right now, right away!
|
|
|
23
23
|
- [Install](#install)
|
|
24
24
|
- [Usage](#usage)
|
|
25
25
|
- [Get started](#get-started)
|
|
26
|
+
- [Running CKB](#running-ckb)
|
|
27
|
+
- [List scripts info](#list-scripts-info)
|
|
26
28
|
- [Create a full-stack Project](#create-a-full-stack-project)
|
|
27
29
|
- [Create a script-only Project](#create-a-script-only-project)
|
|
30
|
+
- [Build and Deploy a script](#build-and-deploy-a-script)
|
|
31
|
+
- [Start the frontend project](#start-the-frontend-project)
|
|
32
|
+
- [Debug a transaction](#debug-a-transaction)
|
|
33
|
+
- [Generate Moleculec bindings](#generate-moleculec-bindings)
|
|
28
34
|
- [Config Setting](#config-setting)
|
|
29
35
|
- [List All Settings](#list-all-settings)
|
|
30
36
|
- [Set CKB version](#set-ckb-version)
|
|
@@ -79,6 +85,61 @@ Commands:
|
|
|
79
85
|
|
|
80
86
|
## Get started
|
|
81
87
|
|
|
88
|
+
### Running CKB
|
|
89
|
+
|
|
90
|
+
Start a local blockchain with the default CKB version:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
offckb node
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Or specify a CKB version:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
offckb node 0.117.0
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Or set the default CKB version:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
offckb config set ckb-version 0.117.0
|
|
106
|
+
offckb node
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Once you start the devnet, there is a RPC server running at `http://localhost:8114`. There is also a RPC proxy server running at `http://localhost:9000` 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.
|
|
110
|
+
|
|
111
|
+
The proxy server is optional, you can use the RPC server directly if you don't need a proxy:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
offckb node --no-proxy
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Or start the proxy server in a standalone terminal to better monitor the logs:
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
offckb proxy-rpc --ckb-rpc http://localhost:8114 --port 9000 --network devnet
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### List scripts info
|
|
124
|
+
|
|
125
|
+
List all the predefined scripts for the blockchain:
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
offckb system-scripts --network devnet
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Or export the scripts info to a lumos JSON file:
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
offckb system-scripts --network devnet --export-style lumos
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Or print the scripts info in a CCC style:
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
offckb system-scripts --network devnet --export-style ccc
|
|
141
|
+
```
|
|
142
|
+
|
|
82
143
|
### Create a full-stack Project
|
|
83
144
|
|
|
84
145
|
Create a new project from predefined boilerplates.
|
|
@@ -99,6 +160,86 @@ offckb create <your-project-name> --script
|
|
|
99
160
|
|
|
100
161
|
Note: you need to have rust/cargo/cargo-generate/clang 16+ installed in your environment to use this command. offckb doesn't do anything really, it just call [ckb-script-template](https://github.com/cryptape/ckb-script-tempaltes) to do all the magic.
|
|
101
162
|
|
|
163
|
+
### Build and Deploy a script
|
|
164
|
+
|
|
165
|
+
The fullstack boilerplate project is a monorepo, which contains a script project and a frontend project.
|
|
166
|
+
|
|
167
|
+
To build the script, in the root of the project, run:
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
make build
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
To deploy the script, cd into the frontend folder and run:
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
offckb deploy --network <devnet/testnet>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Once the deployment is done, you can use the following command to check the deployed scripts:
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
offckb my-scripts --network <devnet/testnet>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Your deployed scripts will be also be listed in the `offckb/my-scripts` folder in your frontend project.
|
|
186
|
+
|
|
187
|
+
### Start the frontend project
|
|
188
|
+
|
|
189
|
+
To start the frontend project, cd into the frontend folder and run:
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
npm run dev
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Debug a transaction
|
|
196
|
+
|
|
197
|
+
If you are using the proxy RPC server, all the failed transactions will be dumped and recorded so you can debug them later.
|
|
198
|
+
|
|
199
|
+
Everytime you run a transaction, you can debug it with the transaction hash:
|
|
200
|
+
|
|
201
|
+
```sh
|
|
202
|
+
offckb debug <transaction-hash>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
If you want to debug a single cell script in the transaction, you can use the following command:
|
|
206
|
+
|
|
207
|
+
```sh
|
|
208
|
+
offckb debug <transaction-hash> --single-script <single-cell-script-option>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The `single-cell-script-option` format is `<cell-type>[<cell-index>].<script-type>`, eg: `"input[0].lock"`
|
|
212
|
+
|
|
213
|
+
- `cell-type` could be `input` or `output`, refers to the cell type
|
|
214
|
+
- `cell-index` is the index of the cell in the transaction
|
|
215
|
+
- `script-type` could be `lock` or `type`, refers to the script type
|
|
216
|
+
|
|
217
|
+
Or you can replace the script with a binary file in your single cell script debug session:
|
|
218
|
+
|
|
219
|
+
```sh
|
|
220
|
+
offckb debug <transaction-hash> --single-script <single-cell-script-option> --bin <path/to/binary/file>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
All the debug utils are borrowed from [ckb-debugger](https://github.com/nervosnetwork/ckb-debugger).
|
|
224
|
+
|
|
225
|
+
### Generate Moleculec bindings
|
|
226
|
+
|
|
227
|
+
[Moleculec](https://github.com/nervosnetwork/molecule) is the official Serialization/Deserialization system for CKB smart contracts.
|
|
228
|
+
|
|
229
|
+
You will define your data structure in `.mol` file(schema), and generate the bindings for different programming languages to use in your development.
|
|
230
|
+
|
|
231
|
+
```sh
|
|
232
|
+
offckb mol --schema <path/to/mol/file> --output <path/to/output/file> --lang <lang>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The `lang` could be `ts`, `js`, `c`, `rs` and `go`.
|
|
236
|
+
|
|
237
|
+
If you have multiple `.mol` files, you can use a folder as the input and specify an output folder:
|
|
238
|
+
|
|
239
|
+
```sh
|
|
240
|
+
offckb mol --schema <path/to/mol/folder> --output-folder <path/to/output/folder> --lang <lang>
|
|
241
|
+
```
|
|
242
|
+
|
|
102
243
|
## Config Setting
|
|
103
244
|
|
|
104
245
|
### List All Settings
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@offckb/cli",
|
|
3
|
-
"version": "0.3.0-canary-
|
|
3
|
+
"version": "0.3.0-canary-201a756.0",
|
|
4
4
|
"description": "ckb development network for your first try",
|
|
5
|
-
"author": "
|
|
5
|
+
"author": "CKB EcoFund",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/ckb-ecofund/offckb.git"
|
|
10
10
|
},
|
|
11
11
|
"main": "dist/cli.js",
|
|
12
12
|
"bin": {
|