Overview
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 smart contracts 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.
This guide provides an introduction to using Rust for developing backend canisters and covers the basic infrastructure of Rust canisters as well as design considerations and observability.
Rust CDK
To support Rust development, the IC SDK includes the Rust canister development kit (Rust CDK).
While using the IC SDK is the typical path for most developers, experienced Rust developers may choose to circumvent the IC SDK entirely and use the Rust CDK directly. This documentation assumes the reader is using the IC SDK to build Rust canisters.
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.