Member-only story
Solidity Tutorial: All About Imports
Dive into import statements with Solidity
Table of Contents
Modules and Code Modularity.Solidity Imports.Types of Solidity Import Syntax.
* Global Import
* Specific ImportsImport Aliases.
* Global Alias
* Alias SpecificWhich import syntax to use?What can you import from a Solidity file?Solidity Import Syntax Cheatsheet
Modules and Code Modularity
Before diving into Import statements in Solidity, let’s first understand modular programming. The concept of modules is very old. It first appeared 44 years ago with the programming languages Modula-2 and Pascal.
The idea behind modules is to break code into reusable components. You group functionalities in a module file and expose them to other files so that these other files can use them.
A module system helps organise your code by grouping variables and functions that make sense together in one single file.
Let’s take the example of modules in Javascript (ES6). In ES6, modules are files that export one or more values (objects, functions or variables). Then, any other…