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
Copy file name to clipboardExpand all lines: README.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ $ create-ckb-scripts
62
62
✨ Done! New project created /tmp/my-first-contract-workspace
63
63
```
64
64
65
-
### Working in the workspace
65
+
### Generating contract crates in the workspace
66
66
67
67
First, navigate to the workspace directory you just created:
68
68
@@ -137,6 +137,24 @@ $ make generate CRATE=second-contract
137
137
✨ Done! New project created /tmp/my-first-contract-workspace/contracts/second-contract
138
138
```
139
139
140
+
By default, the newly created crate is using [contract](https://github.com/xxuejie/ckb-script-templates/tree/main/contract) template, which is put into `contracts` sub-folder, the workspace-level `Makefile` assumes all Rust contracts are stored in `contracts` folder, and treat crates stored in other folders as dependency-only Rust crates.
141
+
142
+
But chances are you would want to tweak the default settings in certain scenarios:
143
+
144
+
* Sometimes you want to use a different template as a contract starting point other than `contract` template.
145
+
* Sometimes you want to use a different template since you are generating a plain Rust crate, which will also likely be put in a different subfolder other than `contracts`
146
+
***Note**: while you could technically put a Rust contract in a different subfolder other than `contracts`, we don't really recommend this, since the workspace-level `Makefile` is leveraging the convention that all CKB contracts live in `contracts` folder.
147
+
148
+
You can do this by customizing parameters to `make generate`:
149
+
150
+
```
151
+
$ make generate TEMPLATE=contract-with-tests # generate a Rust contract crate in contracts subfolder, but use contract-with-tests template
152
+
$ make DESTINATION=crates # generate a crate in crates folder, and still use the default contract template
153
+
$ make generate TEMPLATE=c-wrapper-crate DESTINATION=crates # generate a crate in crates folder, but use c-wrapper-crate template
154
+
```
155
+
156
+
### Build & Test
157
+
140
158
Note that when you supply the contract crate name, our `Makefile` will be smart enough to automatically insert the crate in to `Cargo.toml` file, so you don't have to edit it manually.
141
159
142
160
Now you can build the contracts(or adjust parameters):
0 commit comments