Interfaces
Learn about interfaces in Solidity.
In Solidity, interfaces are pure abstract contracts that define a collection of function declarations but don’t include any statements, implementations, state variables, constructors, or implemented functions. They serve as blueprints for contracts that are intended to follow a specified set of functionalities.
Key characteristics of interfaces
Here are the key characteristics of interfaces:
Pure abstract contracts: Interfaces are essentially pure abstract contracts. They declare functions without providing any implementation details.
Function declarations only: Interface functions include only declarations. They lack executable statements, focusing solely on outlining the function signatures that derived contracts must implement.
External function type: Functions in interfaces are of the external type. This emphasizes their role as entry points for interactions with other contracts.
No constructors or state variables: Interfaces don’t contain constructors or state variables. They are purely a collection of function signatures.
Derivation from other interfaces: Interfaces can derive from other interfaces, providing a mechanism for building modular and extensible function sets.
Enums and structs access: Interfaces can expose enums and structs using the interface name dot notation, allowing contracts implementing the interface to access these data types
Interface declaration
The interface
keyword is used to declare an interface.
Get hands-on with 1200+ tech skills courses.