Importing Source Files in Solidity

This tutorial will show you how to import local and external files.

The compilation result will also contain contracts implemented in the imported files.

For a detailed explanation of the import keyword see the Solidity documentation

Importing a file from the browser’s local storage

Files in Remix can be imported just by specifying their path. Please use ./ for relative paths to increase portability. _images/a-old-tuto_basicimport.png

Importing a file from your computer’s filesystem

This method uses remixd - the remix daemon. Please go to the remixd tutorial for instructions about how to bridge the divide between the browser and your computers filesystem.

Importing from GitHub

It is possible to import files directly from GitHub with URLs like https://github.com/<owner>/<repo>/<path to the file>.

_images/a-old-tuto_importgit.png

Importing from Swarm

Files can be imported using all URLs supported by swarm. If you do not have a swarm node, swarm-gateways.net will be used instead.

_images/a-old-tuto_importswarm.png