Importing Source Files in Solidity
There are multiple techniques for importing files into Remix.
For a tutorial about importing files click here. You can also find this tutorial in the Remix Workshops plugin.
For a detailed explanation of the
import keyword see the
Here are a some of the main methods of importing a file:
Importing a file from the browser's local storage
Files in Remix can be imported with the
import key word with the path to the file. Use
./ for relative paths to increase portability.
pragma solidity >=0.4.22 <0.6.0; import "./ballot.sol";
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.
pragma solidity >=0.4.22 <0.6.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol";
Importing from Swarm
Files can be imported using all URLs supported by swarm. If you do not have a swarm node, then use swarm-gateways.net.
Importing from IPFS
Files can be imported from IPFS.
Importing from the console
You can also use a remix command remix.loadurl('<the_url>')in the console:
Notice that this will create a
github folder in the file explorer. To load a file in the
github folder, you would use a command like this: