Share:
Notifications
Clear all

Earn While Learning Web3 Programming>> Start Here FREE!!!

[Solved] How To Import External Smart Contract In Solidity

1 Posts
1 Users
2 Reactions
295 Views
1
Topic starter

EXERCISE:
i. How do you import Smart Contract In Solidity

ii. Explain in your own word and Post your external smart contract import sample code in this forum below:

(NOTE: please, don't go and copy paste from other students in the forum, try things on your own, so you can master it yourself)

 

 

 

NOTE:

This Is An Exercise From Our FREE Smart Contract Development With Solidity For Beginners Course (If you have not enrolled yet, you can join the course totally for FREE).

 

1 Answer
1
Topic starter

For a smart contract to inherit features from another smart contract (know as Inheritance in Solidity), it need to use the keyword "import" and also reference the imported contract as follows:

 

import "linkt to imported external smart contract";

 

//EXAMPLE

import "./Payable.sol";

contract staffSalary is Payable {

}

EXPLANATION:

After the import line above, you need to reference the imported external smart contract with "is" to ensure the bond is created and the smart contract "staffSalary" now inherit features from an external smart contract "Payable".

 

 

Share: