Inheritance, Abstract Contracts, and Interfaces
Learn to extend the functionality of your smart contracts with code from other smart contracts, abstract contracts, and interfaces.
We'll cover the following...
Inheritance
In object-oriented programming, inheritance is a program’s ability to use another program’s functionality. In Solidity, it allows us to extend our contracts with code that has been proven to be secure and keep them organized and maintainable. The contract providing this code is known as a base contract, whereas the inheriting contract is known as a derived contract.
We declare that a contract inherits from a source using the is
keyword as if to say that the derived contract is an instance of the base contract.
Press + to interact
pragma solidity >=0.4.0 <0.7.0;contract X {}contract Y is X {}contract Z is Y {// This makes Z derive from X as well}
Code from multiple base contracts can be inherited by a single derived ...