Rust CDK
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 ICP.
Developing canisters in Rust is supported on ICP through the Rust canister development kit (CDK), which is developed and maintained by DFINITY. Rust is natively supported by ICP developer tools such as dfx
and PocketIC, and can be used with features such as HTTP certification, composite queries, and query stats.
While using the IC SDK is the typical workflow for most developers to develop Rust canisters, experienced developers may choose to circumvent the IC SDK entirely and use the Rust CDK directly.
The Rust CDK consists of the following crates:
ic-cdk
: Core methods that enable Rust programs to interact with the ICP system API.ic-cdk-macros
: Defines the procedural macros (e.g.,update
,query
,import
) that facilitate building operation endpoints and APIs.ic-cdk-timers
: Provides an API to schedule multiple timers and periodic tasks.
Rustic
Rustic is an extension to ic-cdk
, offering additional primitives and functionalities familiar to Solidity developers, such as AccessControl
and ReentrancyGuard
. It also embeds best practices on canister development and adds syntactic sugar. Stable memory, HTTP metrics, and canister lifecycle management are all available out of the box.
Rust documentation
The Rust CDK documentation can be found on crates.io.
The following documentation pages detail specific Rust workflows, best practices, and considerations: