https://github.com/mujhtech/icp-rust-quiz-example
https://github.com/mujhtech/icp-rust-quiz-example
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mujhtech/icp-rust-quiz-example
- Owner: Mujhtech
- Created: 2023-11-09T05:31:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-13T11:37:07.000Z (over 2 years ago)
- Last Synced: 2025-04-11T01:11:22.301Z (about 1 year ago)
- Language: Rust
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# icp_rust_message_board_contract
### Requirements
* rustc 1.64 or higher
```bash
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
$ source "$HOME/.cargo/env"
```
* rust wasm32-unknown-unknown target
```bash
$ rustup target add wasm32-unknown-unknown
```
* candid-extractor
```bash
$ cargo install candid-extractor
```
* install `dfx`
```bash
$ 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:
```bash
$ cd icp_rust_boilerplate/
$ dfx help
$ dfx canister --help
```
## Update dependencies
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 = { git = "https://github.com/lwshang/stable-structures.git", branch = "lwshang/update_cdk"}
```
## did autogenerate
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.
## Running the project locally
If you want to test your project locally, you can use the following commands:
```bash
# Starts the replica, running in the background
$ dfx start --background
# Deploys your canisters to the replica and generates your candid interface
$ dfx deploy
```