Developer Resources
Example Code
Discover quick code references that showcase code examples for Motoko, Rust, and C++
Code References
Curated set of code examples
Motoko and Rust Examples
The following example is available in both Motoko and Rust.
- Hello: The hello example is the decentralized equivalent of hello world. The webpage is served by a separate frontend and backend canister
Motoko Examples
The Motoko Playground features a range of examples, some of which are featured in the following. You can test Motoko examples in the simple environment of the playground without having to use the Dfinity SDK. However, the playground does not support decentralized applications with frontends.
Basic examples – getting started
Illustrations of the basic concepts of the Motoko programming language and the Internet Computer.
Intermediate examples – use cases of basic concepts
The next set of examples illustrate how you can use simple concepts of Motoko in common use cases. Included are examples of how you can use Motoko to build basic backend functionalities.
Simple frontends – in JavaScript
The previous examples did not include frontends. The following two examples show you how you can create minimal frontends and backends in JavaScript.
Rust Examples
The next set of examples are written in Rust.
Beginner examples – in Rust
Two examples highlighting how you can use Rust:
C
Demo projects written in the programming language C. More examples can be found here: C++ sample projects.