Developer Resources
Motoko Base Library
Learn how you can use the Motoko base modules to minimize built-in types and operations
Using Motoko Base Modules
Learn More about the Motoko Base Library
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.
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:
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:
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.