Solidity Inheritance

whiteboard crypto logo
Published by:
Whiteboard Crypto

The Solidity programming language provides the use of inheritance, which means smart contracts can be built using other contract’s code. Here is a simple example of a contract inheriting two other contracts:

//SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

contract a{
    uint public age = 30;

contract b{
    string public name = "Jerry";

contract c is a,b{
    function getInfo() public view returns(uint, string memory){
        return (age,name);

To inherit another contract in Solidity, when defining the current contract, you simply add the “is” keyword with a comma-separated list of the contracts you wish to inherit.

whiteboard crypto logo

WhiteboardCrypto is the #1 online resource for crypto education that explains topics of the cryptocurrency world using analogies, stories, and examples so that anyone can easily understand them. Growing to over 870,000 Youtube subscribers, the content has been shared around the world, played in public conferences and universities, and even in Congress.