- rustc 1.64 or higher
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
$ source "$HOME/.cargo/env"
- rust wasm32-unknown-unknown target
$ rustup target add wasm32-unknown-unknown
- candid-extractor
$ cargo install candid-extractor
- install
dfx
$ DFX_VERSION=0.15.0 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
$ echo 'export PATH="$PATH:$HOME/bin"' >> "$HOME/.bashrc"
$ source ~/.bashrc
$ dfx start --background
If you want to start working on your project right away, you might want to try the following commands:
$ cd icp_rust_message_board_contract/
$ dfx help
$ dfx canister --help
update the dependencies
block in /src/{canister_name}/Cargo.toml
:
[dependencies]
candid = "0.9.9"
ic-cdk = "0.11.1"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
ic-stable-structures = "0.5.6"
Add this script to the root directory of the project:
https://github.com/buildwithjuno/juno/blob/main/scripts/did.sh
Update line 16 with the name of your canister:
https://github.com/buildwithjuno/juno/blob/main/scripts/did.sh#L16
After this run this script to generate Candid. Important note!
You should run this script each time you modify/add/remove exported functions of the canister. Otherwise, you'll have to modify the candid file manually.
Also, you can add package json with this content:
{
"scripts": {
"generate": "./did.sh && dfx generate",
"gen-deploy": "./did.sh && dfx generate && dfx deploy -y"
}
}
and use commands npm run generate
to generate candid or npm run gen-deploy
to generate candid and to deploy a canister.
If you want to test your project locally, you can use the following commands:
# Starts the replica, running in the background
$ dfx start --background
# Deploys your canisters to the replica and generates your candid interface
$ dfx deploy