Skip to content

sammiepius/icp_rust_shoeStore

Repository files navigation

icp_rust_shoeStore

A canister project build using the rust programming language. It is a shoe storage facility where store owners can:

  1. Add shoe to the store.
  2. get a shoe by the shoe id.
  3. get all the available shoes in the store.
  4. see the total numbers of shoes in store.
  5. search for a shoe using the shoe name.
  6. update and delete a specific shoe by its id and also
  7. like a shoe product.

Requirements

  • 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_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:

# Starts the replica, running in the background
$ dfx start --background

# Deploys your canisters to the replica and generates your candid interface
$ dfx deploy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published