48
Watch
137
Star
65
Fork
70
Issue

Rust canister development kit for the Internet Computer.

dfinity
dfinity
pushedAt 3 days ago

dfinity/cdk-rs

Rust Canister Development Kit

Documentation Crates.io License Downloads CI

Rust CDK provides tools for building Canisters on Internet Computer (IC).

You may be looking for:

If you are looking for a crate to communicate with existing canisters on IC, you may want to check agent-rs.

Introduction

A canister is a WebAssembly (wasm) module that can run on the Internet Computer.

To be a canister, a wasm module should communicate with the execution environment using Canister interfaces (System API).

This repo provides libraries and tools to facilitate developing canisters in Rust.

  • ic-cdk: Bindings of the System API.
  • ic-cdk-macros: Annotate functions with attribute macros to make them exposed public interfaces.
  • ic-certified-map: An implementation of map which support certified queries.
  • ic-ledger-types: Type definitions to communicate with the ICP ledger canister.

Rust CDK in Action

In Cargo.toml:

[lib]
crate-type = ["cdylib"]

[dependencies]
candid = "0.8.0" # this is required if you want to use the `#[import]` macro
ic-cdk = "0.6"

Then in your rust source code:

#[ic_cdk::query]
fn print() {
    ic_cdk::print("Hello World from DFINITY!");
}

Check tutorial for a detailed guidance.