Skip to content

Instantly share code, notes, and snippets.

@BellaBe
Created December 29, 2022 15:16
Show Gist options
  • Save BellaBe/b4e670c1aa8ad7cb7baa506ce228b8fc to your computer and use it in GitHub Desktop.
Save BellaBe/b4e670c1aa8ad7cb7baa506ce228b8fc to your computer and use it in GitHub Desktop.
Parent child single inheritance Smart contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract ParentContract{
uint internal simpleInteger;
function setInteger(uint _value) external{
simpleInteger = _value;
}
}
contract ChildContract is ParentContract{
bool private simpleBool;
function getInteger() public view returns(uint){
return simpleInteger;
}
}
contract Client {
ChildContract pc = new ChildContract();
function workWithInheritance() public returns (uint){
pc.setInteger(100);
return pc.getInteger();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment