VOOZH about

URL: https://www.geeksforgeeks.org/solidity/solidity-basics-of-interface/

⇱ Solidity - Basics of Interface - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Solidity - Basics of Interface

Last Updated : 9 Mar, 2023

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 : 

👁 Interface Example


 

Comment
Article Tags:

Explore