Member-only story
Solidity Tutorial: all about interfaces

When you flip a light switch, the light goes on.
You do not care “how” the switch turns the light on.
You just care that “it does turn the light on”.
Table of Contents
The idea behind interfaces
What are smart contract interfaces?
Interfaces in Solidity
How to define and use an interface in Solidity?
Functions defined inside an interface.
Function visibility inside interfaces
Benefits of using contract interfaces
Types defined inside an interface
Interfaces and inheritance
Function overloading inside interfaces
Defining events inside interfaces
interfaces and their JSON ABIs
What cannot be defined inside an interface
Security Considerations around interfaces
Useful tools for interfaces
References
The idea behind interfaces
Interfaces are a standard building block and feature of many programming languages. They aim to separate the definition of functionality (a function) from the actual behaviour of the functionality itself.
Let’s use the concept of a light switch mentioned above as an example. Many types of switches (so implementations) exist when you think about it. Here are some examples:
- types of light switches: https://www.electronicshub.org/different-types-of-light-switches/
- or to go a bit further -> types of switches (in general): https://learn.sparkfun.com/tutorials/button-and-switch-basics/all