You can define interfaces in Solidity using the interface keyword. These interfaces are very similar to abstract contracts, and they must not have any function definitions. They also have the following restrictions:
- All the functions that are defined in the interface must have external visibility.
- The constructor is not allowed.
- An interface cannot have any state variables defined.
- The interfaces cannot inherit from any other contracts or interfaces.
There are some differences between the Solidity 0.4.25 and 0.5.0 version interfaces. In version 0.4.25, you cannot define enum and struct. However, with version 0.5.0 onward, you can define them.
The following example shows an interface that's been defined in Solidity version 0.4.25, having a function declared without the body:
pragma solidity ^0.4.25;
interface ExampleInterface {
function transfer...