Tutorials: Writing actor-based programs

The default sample program in Getting started illustrated the basic work flow for creating projects and deploying sample code to run on an Internet Computer node.

Next, we’ll explore writing a few simple programs using the Motoko language to give you hands-on experience working with the code. One of the keys for writing programs in Motoko is that it is optimized for handling asynchronous messaging while maintaining type soundness and an approachable interface with language conventions that look familiar to most developers.

The following tutorials introduce the basics for working with Motoko:

  • Using an actor in Hello, World!

    In the first tutorial, you are going to replace the typical print function usually defined in a "Hello, World!" program by defining an actor (object) with a hello function.

  • Passing arguments in a terminal

    In the second tutorial, you are going to see the different ways you can pass string arguments to a function on a deployed canister using the command-line in a terminal shell.

  • Incrementing a value to illustrate persistence

    In this tutorial, you are going to write a program that creates an actor and provides a few basic functions to increment and return the value of a counter.

  • Exploring calculator functions

    In this tutorial, you are going to write a simple calculator program for more practice working with Motoko and to learn more about how you can customize your project environment.

  • Importing standard library functions

    In this tutorial, you are going to write a simple program that illustrates how to import and use a few basic standard library functions for working with key-value pairs in a list using Motoko.

  • Using multiple actors

    In this tutorial, you are going to create a single project that include multiple unrelated actors to illustrate how you can compile multiple canisters for the same project.

  • Customizing the front-end

    This tutorial illustrates using a simple React framework to create a new front-end for the default sample program and guides you through some basic modifications to customize the interface displayed. If you already know how to use CSS, HTML, JavaScript, and React or other frameworks to build your user interface, you can skip this tutorial.

  • Adding a stylesheet

    This tutorial illustrates how to add a stylesheet when you use React to create a new front-end for your project. If you already know how to add stylesheets to React, you can skip this tutorial.

  • Calling shared functions

    This tutorial illustrates how to call shared functions in one canister from a program in another canister.

Additional tutorials covering more advanced programs and more detailed examples of how to use the basic building blocks are available in the Motoko Programming Language Reference.