Skip to content

standardize README #1193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions rust/backend_wasm64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,31 @@ This backend-only project demonstrates how to write a simple smart contract for

This example specifically showcases building and deploying canisters compiled to the Wasm64 target, which provides access to 64-bit memory addressing and can handle larger memory spaces compared to the traditional Wasm32 target.

This application's logic is written in [Rust](https://internetcomputer.org/docs/building-apps/developer-tools/cdks/rust/intro-to-rust), a programming language that can be used develop canisters on ICP.

## Deploying from ICP Ninja

When viewing this project in ICP Ninja, you can deploy it directly to the mainnet for free by clicking "Deploy" in the upper right corner. Open this project in ICP Ninja:

[![](https://icp.ninja/assets/open.svg)](https://icp.ninja/i?g=https://github.com/dfinity/examples/rust/backend_wasm64)


## What is Wasm64?

The Wasm64 target allows canisters to:
- Access larger memory spaces (up to 6GiB, compared to the 4GiB limit of Wasm32)
- Use 64-bit memory addressing

This example always builds for Wasm64 using Rust's nightly toolchain and the `-Z build-std` feature.
This example uses the `build.sh` script to build for Wasm64 using Rust's nightly toolchain and the `-Z build-std` feature.

## Project structure
## Deploying from ICP Ninja

The `/backend` folder contains the Rust smart contract, which uses the following files:
When viewing this project in ICP Ninja, you can deploy it directly to the mainnet for free by clicking "Deploy" in the upper right corner. Open this project in ICP Ninja:

- `Cargo.toml`, which defines the crate that will form the backend.
- `lib.rs`, which contains the actual smart contract, and exports its interface.
- The `build.sh` script that automatically builds for Wasm64 using the nightly toolchain.
[![](https://icp.ninja/assets/open.svg)](https://icp.ninja/i?g=https://github.com/dfinity/examples/rust/backend_wasm64)

## Build and deploy from the command-line

To build and deploy this Wasm64 example locally, follow the instructions in the `BUILD.md` file.
### 1. [Download and install the IC SDK.](https://internetcomputer.org/docs/building-apps/getting-started/install)

### 2. Download your project from ICP Ninja using the 'Download files' button on the upper left corner, or [clone the GitHub examples repository.](https://github.com/dfinity/examples/)

### 3. Navigate into the project's directory.

### 4. Run `dfx start --background --clean && dfx deploy` to deploy the project to your local environment.

## Security considerations and best practices

The build process will automatically:
1. Install the Rust nightly toolchain if needed.
2. Add the `rust-src` component for `build-std`.
3. Build the canister for the `wasm64-unknown-unknown` target.
4. Extract the Candid interface.
5. Prepare the Wasm file for deployment.
If you base your application on this example, it is recommended that you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/building-apps/security/overview) for developing on ICP. This example may not implement all the best practices.

Loading