![]() |
VOOZH | about |
Interfaces are the same as abstract contracts created by using an interface keyword, also known as a pure abstract contract. Interfaces do not have any definition or any state variables, constructors, or any function with implementation, they only contain function declarations i.e. functions in interfaces do not have any statements. Functions of Interface can be only of type external. They can inherit from other interfaces, but they can't inherit from other contracts. An interface can have enum, structs which can be accessed using interface name dot notation.
Example: In the below example, the contract MyContract implements an interface from the InterfaceExample.sol file and implements all the interface functions. Import the InterfaceExample.sol file into the MyContract.sol file before deploying it.
InterfaceExample.sol :
MyContract.sol:
Output :