You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[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:
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:
- 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:
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.
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:
0 commit comments