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
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-templates) to do all the magic.
210
211
212
+
### Create a dApp-only Project
213
+
214
+
You can create a new dApp project without the script(CKB Smart Contract). This is useful when you don't need to create your own on-chain script logic.
215
+
216
+
```sh
217
+
offckb create <your-project-name> --dapp # or -d
218
+
```
219
+
211
220
### Build and Deploy a script
212
221
213
222
The fullstack boilerplate project is a monorepo, which contains a script project and a frontend project.
Check example at https://github.com/nervosnetwork/docs.nervos.org/tree/develop/examples/simple-transfer
43
+
Check more on how to integrate offckb config to develop your app at https://docs.nervos.org/docs/getting-started/quick-start#different-frontend-framework
44
+
A Full example can also be found at https://github.com/nervosnetwork/docs.nervos.org/tree/develop/examples/simple-transfer
This is a Minimal Template for CKB Full-Stack Dapps generated by [offckb](https://github.com/RetricSu/offckb).
4
+
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:
6
+
7
+
-[ckb-js-vm](https://github.com/nervosnetwork/ckb-js-vm) 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
+
To start the project, install the dependecies:
11
+
12
+
```bash
13
+
pnpm i
14
+
```
15
+
16
+
## Script(Smart Contract)
17
+
18
+
The on-chain script project is powered by [ckb-js-vm](https://github.com/nervosnetwork/ckb-js-vm) bootstrapped with [`create-ckb-js-vm-app`](https://github.com/nervosnetwork/ckb-js-vm).
19
+
20
+
Build on-chain script:
21
+
22
+
```bash
23
+
pnpm build
24
+
```
25
+
26
+
Test on-chain script:
27
+
28
+
```bash
29
+
pnpm test
30
+
```
31
+
32
+
## dApp frontend development
33
+
34
+
first, enter the frontend workspace:
35
+
36
+
```sh
37
+
cd frontend
38
+
```
39
+
40
+
start the app:
41
+
42
+
```sh
43
+
pnpm dev
44
+
```
45
+
46
+
change the CKB blockchain network:
47
+
48
+
edit `.env` file:
49
+
50
+
```bash
51
+
NEXT_PUBLIC_NETWORK=devnet # devnet, testnet or mainnet
52
+
```
53
+
54
+
## Deploy to devnet/testnet with offckb
55
+
56
+
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.
57
+
58
+
If you want to test them in devnet/testnet blockchain, then `offckb` might be the ideal selection.
59
+
60
+
`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:
61
+
62
+
```sh
63
+
cd frontend
64
+
offckb deploy --network devnet
65
+
```
66
+
67
+
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.
68
+
69
+
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.
70
+
71
+
You can also deploy smart contracts to the CKB Testnet like this:
72
+
73
+
```sh
74
+
cd frontend
75
+
offckb deploy --network testnet
76
+
```
77
+
78
+
and start your frontend Dapp targeting Testnet:
79
+
80
+
edit `.env` file:
81
+
82
+
```bash
83
+
NEXT_PUBLIC_NETWORK=testnet # devnet, testnet or mainnet
84
+
```
85
+
86
+
```bash
87
+
cd frontend
88
+
pnpm dev
89
+
```
90
+
91
+
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