Skip to main content

Introduction to developing canisters in Rust

Beginner
Rust

Rust is a powerful and type-sound modern programming language with an active developer community. Because Rust compiles to WebAssembly, it offers a rich development environment for writing dapps to run on the BigFile blockchain.

Overview

To help pave the way for writing dapps in Rust that can be deployed on the BigFile blockchain, you can use the BIG SDK. The BIG SDK supports the Rust as well as the Motoko programming language. To create a Rust project using the BIG SDK, all one needs to do is add the --type=rust flag while creating a new project. For example, here you create a Rust project named hello_world:

Use dfx new <project_name> to create a new project:

dfx new hello_world

You will be prompted to select the language that your backend canister will use. Select 'Rust':

? Select a backend language: ›
Motoko
❯ Rust
TypeScript (Azle)
Python (Kybra)

To start a new project see Rust quick start.

Architecture

To support Rust development, the BIG SDK includes the Rust canister development kit (Rust CDK).

While using the BIG SDK is the typical path for most developers, experienced Rust developers may choose to circumvent BIG SDK entirely and use the Rust CDK directly. This documentation assumes one is using the BIG SDK to build Rust canisters.

The Rust CDK consists of the following crates:

  • The core of Rust CDK is the ic-cdk crate. It provides the core methods that enable Rust programs to interact with the BigFile blockchain system API.

  • The ic-cdk-macros crate defines the procedural macros (e.g. update, query, import) that facilitate building operation endpoints and APIs.

  • Also, the ic-cdk-timers crate provides an API to schedule multiple and periodic tasks.

There are a few examples to get you started building Rust Canisters.