Skip to content

Commit 05b62d0

Browse files
authored
docs: update develop.md (#225)
* docs: update develop.md * docs: update other readme
1 parent eea3da1 commit 05b62d0

4 files changed

Lines changed: 221 additions & 10 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ Start building on CKB blockchain, right now, right away!
5252
npm install -g @offckb/cli
5353
```
5454

55+
or use `pnpm` to install:
56+
57+
```sh
58+
pnpm install -g @offckb/cli
59+
```
60+
5561
_We recommend using [LTS](https://nodejs.org/en/download/package-manager) version of Node to run `offckb`_
5662

5763
## Usage

docs/develop.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ edit the things in `templates/v${version}`
2626

2727
### Install dependencies
2828

29-
Since we use `pnpm` as a developing package manager, people install `offckb` by `npm` would require a `package-lock.json` file.
29+
Since we use `pnpm` as a developing package manager, people install `offckb` by `npm` would require a [`npm-shrinkwrap.json`](https://docs.npmjs.com/cli/v8/commands/npm-shrinkwrap) file.
30+
31+
When updating the dependencies, remember to run the following command to generate the `npm-shrinkwrap.json` file.
3032

3133
```sh
32-
npm i --package-lock-only
34+
pnpm add <new-dependency>
35+
36+
// run the following to keep npm-shrinkwrap consistent with out pnpm-lock.json
37+
38+
npm shrinkwrap
3339
```
3440

3541
Remember to run the above command when trying to publish a new version.
Lines changed: 101 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,104 @@
1-
# next-js-template-1
1+
# offckb-template
22

3-
TODO: Write this readme
3+
This is a Minimal Template for CKB Full-Stack Dapps generated by [offckb](https://github.com/RetricSu/offckb).
44

5-
_This project was bootstrapped with [ckb-script-templates]._
5+
Offckb does not do the magic. It just wraps the new CKB smart contract template and the CKB javascript Dapp framework into one mono-repo. Under the hook, it uses:
66

7-
[ckb-script-templates]: https://github.com/cryptape/ckb-script-templates
7+
- [ckb-scripts-template](https://github.com/cryptape/ckb-script-templates) for smart contract development
8+
- [next-js](https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app) and [ccc](https://github.com/ckb-devrel/ccc) for frontend development
9+
10+
## Smart contract development
11+
12+
By default, this template comes with a single simple smart contract `hello-world`: `contracts/hello-world/src/main.rs`.
13+
14+
The smart contract is written in Rust lang. In order to develop, the following dependencies are required:
15+
16+
- `git`, `make`, `sed`, `bash`, `sha256sum` and others Unix utilities.
17+
- `Rust` with `riscv64 target`: `rustup target add riscv64imac-unknown-none-elf`
18+
- `Clang 18+`
19+
- `cargo-generate`
20+
21+
Check out the ckb-script-templates for more [detail](https://github.com/cryptape/ckb-script-templates/blob/main/README.md#dependencies)
22+
23+
### Usage
24+
25+
add a new smart-contract:
26+
27+
```sh
28+
make generate
29+
```
30+
31+
build smart-contract:
32+
33+
```sh
34+
make build
35+
```
36+
37+
run test:
38+
39+
```sh
40+
make test
41+
```
42+
43+
For more detail, check out [ckb-script-templates](https://github.com/cryptape/ckb-script-templates)
44+
45+
## dApp frontend development
46+
47+
first, enter the frontend workspace:
48+
49+
```sh
50+
cd frontend
51+
```
52+
53+
start the app:
54+
55+
```sh
56+
npm i && npm run dev
57+
```
58+
59+
change the CKB blockchain network:
60+
61+
edit `.env` file:
62+
63+
```bash
64+
NEXT_PUBLIC_NETWORK=devnet # devnet, testnet or mainnet
65+
```
66+
67+
## Deploy to devnet/testnet with offckb
68+
69+
Once you build your smart contracts, you can deploy them to CKB blockchain with [ckb-cli](https://github.com/nervosnetwork/ckb-cli) or any other tools.
70+
71+
If you want to test them in devnet/testnet blockchain, then `offckb` might be the ideal selection.
72+
73+
`offckb` will look for the `offckb.config.ts` file to read config information. so you will need to enter the frontend workspace to do the instruction:
74+
75+
```sh
76+
cd frontend
77+
offckb deploy --network devnet
78+
```
79+
80+
If successfully deployed, you will see the deploy script info for your smart contract recorded in the path recorded in the `offckb.config.ts` file.
81+
82+
Every time you deploy a new version of your smart contracts, those script infos will be updated by `offckb` in the place recorded in `offckb.config.ts` and work out-of-box in your frontend.
83+
84+
You can also deploy smart contracts to the CKB Testnet like this:
85+
86+
```sh
87+
cd frontend
88+
offckb deploy --network testnet
89+
```
90+
91+
and start your frontend Dapp targeting Testnet:
92+
93+
edit `.env` file:
94+
95+
```bash
96+
NEXT_PUBLIC_NETWORK=testnet # devnet, testnet or mainnet
97+
```
98+
99+
```bash
100+
cd frontend
101+
npm run dev
102+
```
103+
104+
Note that the `mainnet` network is not supported in `offckb` since `offckb` is focusing on building a friendly development environment for CKB. To gain better security, it is recommended to use production tools like [ckb-cli](https://github.com/nervosnetwork/ckb-cli) to deploy smart contracts and do transactions for the CKB mainnet.
Lines changed: 106 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,109 @@
1-
# temp-template
1+
# offckb-template
22

3-
TODO: Write this readme
3+
This is a Minimal Template for CKB Full-Stack Dapps generated by [offckb](https://github.com/RetricSu/offckb).
44

5-
_This project was bootstrapped with [ckb-script-templates]._
5+
Offckb does not do the magic. It just wraps the new CKB smart contract template and the CKB javascript Dapp framework into one mono-repo. Under the hook, it uses:
66

7-
[ckb-script-templates]: https://github.com/cryptape/ckb-script-templates
7+
- [ckb-scripts-template](https://github.com/cryptape/ckb-script-templates) for smart contract development
8+
- [remix-vite](https://remix.run/tutorials/blog) and [CCC](https://github.com/ckb-devrel/ccc) for frontend development
9+
10+
## Smart contract development
11+
12+
By default, this template comes with a single simple smart contract `hello-world`: `contracts/hello-world/src/main.rs`.
13+
14+
The smart contract is written in Rust lang. In order to develop, the following dependencies are required:
15+
16+
- `git`, `make`, `sed`, `bash`, `sha256sum` and others Unix utilities.
17+
- `Rust` with `riscv64 target`: `rustup target add riscv64imac-unknown-none-elf`
18+
- `Clang 18+`
19+
- `cargo-generate`
20+
21+
Check out the ckb-script-templates for more [detail](https://github.com/cryptape/ckb-script-templates/blob/main/README.md#dependencies)
22+
23+
### Usage
24+
25+
add a new smart-contract:
26+
27+
```sh
28+
make generate
29+
```
30+
31+
build smart-contract:
32+
33+
```sh
34+
make build
35+
```
36+
37+
run test:
38+
39+
```sh
40+
make test
41+
```
42+
43+
run test with contract-debug logs:
44+
45+
```sh
46+
cargo test -- --nocapture
47+
```
48+
49+
For more detail, check out [ckb-script-templates](https://github.com/cryptape/ckb-script-templates)
50+
51+
## Dapp frontend development
52+
53+
first, enter the frontend workspace:
54+
55+
```sh
56+
cd frontend
57+
```
58+
59+
start the app:
60+
61+
```sh
62+
npm i && npm run dev
63+
```
64+
65+
change the CKB blockchain network:
66+
67+
```sh
68+
export NETWORK=devnet # or testnet, mainnet
69+
npm run dev
70+
```
71+
72+
or
73+
74+
```sh
75+
NETWORK=devnet npm run dev
76+
```
77+
78+
## Deploy to devnet/testnet with offckb
79+
80+
Once you build your smart contracts, you can deploy them to CKB blockchain with [ckb-cli](https://github.com/nervosnetwork/ckb-cli) or any other tools.
81+
82+
If you want to test them in devnet/testnet blockchain, then `offckb` might be the ideal selection.
83+
84+
`offckb` will look for the `offckb.config.ts` file to read config information. so you will need to enter the frontend workspace to do the instruction:
85+
86+
```sh
87+
cd frontend
88+
offckb deploy --network devnet
89+
```
90+
91+
If successfully deployed, you will see the deploy script info for your smart contract recorded in the path recorded in the `offckb.config.ts` file.
92+
93+
Every time you deploy a new version of your smart contracts, those script infos will be updated by `offckb` in the place recorded in `offckb.config.ts` and work out-of-box in your frontend.
94+
95+
You can also deploy smart contracts to the CKB Testnet like this:
96+
97+
```sh
98+
cd frontend
99+
offckb deploy --network testnet
100+
```
101+
102+
and start your frontend Dapp targeting Testnet:
103+
104+
```sh
105+
cd frontend
106+
NETWORK=testnet npm run dev
107+
```
108+
109+
Note that the `mainnet` network is not supported in `offckb` since `offckb` is focusing on building a friendly development environment for CKB. To gain better security, it is recommended to use production tools like [ckb-cli](https://github.com/nervosnetwork/ckb-cli) to deploy smart contracts and do transactions for the CKB mainnet.

0 commit comments

Comments
 (0)