MCPcopy Index your code
hub / github.com/dfinity/cdk-rs

github.com/dfinity/cdk-rs @executor-2.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release executor-2.0.0 ↗ · + Follow
1,233 symbols 2,372 edges 89 files 269 documented · 22%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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.

  • ic0: Internet Computer System API binding.
  • ic-cdk: Internet Computer Canister Development Kit.
  • ic-cdk-bindgen: Generate Rust bindings from Candid to make inter-canister calls.
  • ic-cdk-macros: Annotate functions with attribute macros to make them exposed public interfaces.
  • ic-cdk-timers: The library implements multiple and periodic timers.
  • ic-management-canister-types: Types for calling the IC management canister.
  • 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]
ic-cdk = "0.18"
candid = "0.10" # required if you want to define Candid data types

Then in Rust source code:

#[ic_cdk::query]
fn hello() -> String{
    "world".to_string()
}

Check Rust quickstart for a detailed guidance.

Extension points exported contracts — how you extend this code

CallErrorExt (Interface)
Extension trait for error types to provide additional methods. [7 implementers]
ic-cdk/src/call.rs
AsHashTree (Interface)
Types that can be converted into a [`HashTree`]. [3 implementers]
library/ic-certified-map/src/rbtree.rs
OptimizationPass (Interface)
(no doc) [2 implementers]
legacy/ic-cdk-optimizer/src/passes.rs
SerialClosure (Interface)
(no doc) [1 implementers]
ic-cdk-timers/src/state.rs
StableMemory (Interface)
A trait defining the stable memory API which each canister running on the IC can make use of [2 implementers]
ic-cdk/src/stable.rs
StableMemory (Interface)
A trait defining the stable memory API which each canister running on the IC can make use of [1 implementers]
ic-cdk/src/api/stable/mod.rs

Core symbols most depended-on inside this repo

with_arg
called by 67
ic-cdk/src/call.rs
canister_self
called by 55
ic-cdk/src/api.rs
as_ref
called by 53
library/ic-certified-map/src/rbtree.rs
candid
called by 52
ic-cdk/src/call.rs
go
called by 39
library/ic-certified-map/src/rbtree.rs
msg_reply
called by 32
ic0/src/sys.rs
get
called by 23
library/ic-certified-map/src/rbtree.rs
call
called by 22
ic-cdk/src/api/call.rs

Shape

Function 758
Class 212
Method 200
Enum 57
Interface 6

Languages

Rust100%

Modules by API surface

ic-management-canister-types/src/lib.rs86 symbols
library/ic-certified-map/src/rbtree.rs74 symbols
ic0/src/lib.rs73 symbols
ic0/src/sys.rs61 symbols
ic-cdk/src/api.rs58 symbols
library/ic-ledger-types/src/lib.rs54 symbols
ic-cdk/src/management_canister.rs53 symbols
ic-cdk/src/api/call.rs53 symbols
ic-cdk/src/call.rs45 symbols
ic-cdk/src/api/management_canister/main/types.rs41 symbols
ic-cdk/src/stable.rs40 symbols
ic-management-canister-types/tests/candid_equality.rs37 symbols

For agents

$ claude mcp add cdk-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact