How to Use Import in Solidity.
Solidity provides a way to import a file and its contracts or functionalities into another solidity file, The imported file's functionalities can then be used and interacted with within this file. For example, let us create a file with the name project.sol, contracts, and functions can be added to this file.
We also create another solidity file named testProject.sol. To import the project.sol file and its functionalities into the testProject.sol, we write the import keyword followed by the file directory in the testProject.sol file.
Import "browser/project.sol
When this is added to the file it is been imported to, all the contract functionalities are also imported into this file.
This added contract and functions can only be added when we create a new contract into the file which we imported the other .sol. file into. We add the contract functionalities in the previous file using the keyword is followed by the name of the solidity file.
In our example, in order to import the contract named project from the previous solidity file, we create a contract, with a name and use the keyword is followed by the name of the contract we want to import.
This can be written:
We can also use imports as a remote source. What this means is that you can add an external source file into your solidity file remotely using imports.
For example, importing a file from GitHub can be done as shown below.
This means that all contract functionalities included in the .sol file from Github will be imported and can be used by the file.
This is basically how you can use Import in solidity to import files, locally and remotely. To get more Articles about Solidity and follow my Journey learning Solidity with the 100DaysOfSolidity Challenge, you can follow me on Twiitter
check out other resources on how to use imports in Solidity. (betterprogramming.pub/how-to-import-externa..)