Skip to content

Commit 4200482

Browse files
committed
Update README
1 parent 53e5150 commit 4200482

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ $ create-ckb-scripts
6262
✨ Done! New project created /tmp/my-first-contract-workspace
6363
```
6464

65-
### Working in the workspace
65+
### Generating contract crates in the workspace
6666

6767
First, navigate to the workspace directory you just created:
6868

@@ -137,6 +137,24 @@ $ make generate CRATE=second-contract
137137
✨ Done! New project created /tmp/my-first-contract-workspace/contracts/second-contract
138138
```
139139

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+
140158
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.
141159

142160
Now you can build the contracts(or adjust parameters):

0 commit comments

Comments
 (0)