/icp-hello-world-rust

A quick and easy way to develop for the Internet Computer in Rust on macOS, Windows or Linux.

Primary LanguageJavaScriptOtherNOASSERTION

ICP Hello World Rust

This repository provides a quick and easy way to start developing a canister smart contract for the Internet Computer in Rust. The repository can be used with macOS, Windows or Linux.

Getting Started

To get started with Gitpod, click the button below:

Open in Gitpod

If you rather want to use GitHub Codespaces, click this button instead:

Open in GitHub Codespaces

If you prefer running VS Code locally and not in the browser, click "Codespaces: ..." or "Gitpod" in the bottom left corner and select "Open in VS Code" in the menu that appears. If prompted, proceed by installing the recommended plugins for VS Code.

Running your Project

After the IDE has opened, run dfx deploy in the terminal to deploy the frontend and backend. Click on the first green link at the end of the output to see your canister's frontend in the browser. To interact with the backend canister, click on the second green link. NOTE: When developing in GitHub Codespaces, run ./scripts/canister_urls.py and use the links that are shown there.

For interactive development of the frontend canister, you can also start a node server by running npm start. You can find your canister's frontend running under http://localhost:8080.

If you make changes to the backend canister, remember to call dfx deploy first; it suffices to reload the frontend canister's webpage to reflect the changes you've made. If your environment was restarted or has been inactive over some time, you might need to run dfx start --background before running dfx deploy.

Testing your Project

To run the integration tests for your backend canister, first run dfx build to build the canister Wasm, and then cargo test --test integration_tests. If the canisters have not yet been created, run dfx canister create --all before dfx build.

Local Development

If you prefer to develop locally, first install Docker and VS Code and start them on your machine. Next, click the following button to open the dev container locally:

Open locally in Dev Containers

If prompted, install the required/recommended plugins for VS Code.

Documentation and Guides

To learn more before you start working on this project, see the following documentation available online:

If you want to start working on your project right away, you might want to try the following commands to familiarize yourself with dfx:

dfx help
dfx canister --help