Developer Resources

Motoko Base Library

Learn how you can use the Motoko base modules to minimize built-in types and operations

IC Academy » Developer Resources » Motoko Base Library

Using Motoko Base Modules

Learn More about the Motoko Base Library

The following explores how developers can use the Motoko base modules. To learn more about Motoko, have a look at our Introduction to the Motoko Programming Language.

Motoko is designed to minimize operations and built-in types. This is accomplished by providing a base library consisting of modules that handle common operations. It is an ever evolving base library supporting the base library APIs and core features.

Please note that the base library will likely increase. For this reason, updates to its modules may introduce breaking changes to your programs if they are not updated.

Importing Modules from the Base Library

You can use of the import keyword to import materials from the base library. To do so, use import followed by the local module name and the URL where the declaration can find to module.

Here’s an example:

Copy to Clipboard

The example above illustrates how you can import Motoko code — which is indicated by the mo: prefix. It uses the base library path /base as well as the Debug module. Another way to import Motoko code as well as library modules is to use relative paths.

Let’s say you’ve written a Motoko program called types.mo located in the folder of your main program. Your program can be included with the following import declaration:

Copy to Clipboard

Viewing Base Library Modules

You can view the developer documentation and the source code of base library modules in the open source repository motoko-base. The repository contains instructions on how you can generate a local copy of the Motoko base library documentation. Alternatively, use Search in the Developer Center.

Introduction to Motoko

Learn More about the Internet Computer’s native language and how it empowers developers

More about Motoko

Discover Motoko’s Features

Learn more about the developer productivity features that Motoko offers to developers

Developer productivity features