Follow https://github.com/cryptape/ckb-script-templates
git
,make
,sed
,bash
,sha256sum
(you have these on most unix compatible systems)rust
, follow: https://rustup.rs/ , and do:rustup target add riscv64imac-unknown-none-elf
llvm
> 16cargo-generate
,cargo install cargo-generate
cargo generate gh:cryptape/ckb-script-templates workspace --name my-first-contract
cd my-first-contract
Generate a contract with a given name
make generate
🤷 Project Name: my-contract
🔧 Destination: ./my-first-contract/contracts/my-contract ...
🔧 project-name: my-contract ...
🔧 Generating template ...
🔧 Moving generated files into: `./tutorial-contract/contracts/my-contract`...
🔧 Initializing a fresh Git repository
✨ Done! New project created ./tutorial-contract/contracts/my-contract
open ./contracts/my-contract
, fill your logic in src/main.rs
test cases goes into tests/tests.rs
, you can also use your own project structure.
- run
make build MODE=debug
to build your contract - run
make test
to test your contract
- build your contract a release binary:
make build MODE=release
- ensure you have installed ckb-cli: https://github.com/nervosnetwork/ckb-cli
- generate a deployment info:
ckb-cli --url https://testnet.ckb.dev/rpc deploy init-config --deployment-config deploy.yaml --output-format yaml
- generate your deployment tx, and sign it:
mkdir -p ./migration && ckb-cli --url https://testnet.ckb.dev/rpc deploy gen-txs --info-file deploy.toml --migration-dir migration --from-address YOUR_ADDRESS --fee-rate 1000 --deployment-config deploy.yaml --sign-now
- send your tx:
deploy apply-txs --info-file deploy.toml --migration-dir ./migration