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
This is a Minimal Template for CKB Full-Stack Dapps generated by [offckb](https://github.com/RetricSu/offckb).
3
+
TODO: Write this readme
4
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:
5
+
_This project was bootstrapped with [ckb-script-templates]._
6
6
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 [Lumos](https://github.com/ckb-js/lumos) 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 16+`
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 `offckb.config.ts` file. You can then directly import and use your smart contract in your frontend Dapp like this:
Every time you deploy a new version of your smart contracts, those script infos will be updated by `offckb` in the `offckb.config.ts` and work out-of-box in your frontend.
97
-
98
-
You can also deploy smart contracts to the CKB Testnet like this:
99
-
100
-
```sh
101
-
cd frontend
102
-
offckb deploy --network testnet
103
-
```
104
-
105
-
and start your frontend Dapp targeting Testnet:
106
-
107
-
edit `.env` file:
108
-
109
-
```bash
110
-
NEXT_PUBLIC_NETWORK=testnet # devnet, testnet or mainnet
111
-
```
112
-
113
-
```bash
114
-
cd frontend
115
-
npm run dev
116
-
```
117
-
118
-
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