Interfaces
Interfaces are like abstract contracts, but there are differences. Interfaces cannot contain any definitions; they can only contain function declarations. It means functions in interfaces cannot contain any code. They are also known as pure abstract contracts.
An interface can contain only the signature of functions. It also cannot contain any state variables. It cannot inherit from other contracts or contain enums or structures. However, interfaces can inherit other interfaces. The function signatures terminate using the semicolon (;
) character. Interfaces are declared using the interface
keyword followed by an identifier. The following code block shows an implementation of an interface. The IHelloWorld
interface is defined, containing two function signatures—GetValue
and SetValue
. There are no functions containing any implementation. IHelloWorld
is implemented by the HelloWorld
contract. Contracts that intent to use this contract would create an instance as...