# How to setup solidity inheritance?

Im trying to create a flow where contract A holds an address and all calls from contract B and contract C need to pass a simple msg.sender == systemAddress check.

All the while I need to be able to use any data in contract B within Contract C including the functions.

Here is a basic structure - not working, just trying to convey what I want to achieve. Any help would be greatly appreciated.

``````pragma solidity ^0.8.0;

contract A {

constructor(){}

function fromSystem(address from) public view {
require(
"Invalid transaction source"
);
}
}

contract B {

A a;

uint[] data;

a = A(contractA);
data.push(10);
}

modifier fromSystem() {
a.fromSystem(msg.sender);
_;
}

function funcB() public fromSystem returns (uint256){
// do something
return data;
}
}

contract C {

A a;
B b;

a = A(contractB);
b = B(contractB);
}

modifier fromSystem() {
a.fromSystem(msg.sender);
_;
}

function funcC() public fromSystem {
uint num = b.funcB();
// expecting 10
}
}

``````

Solidity supports multiple inheritance. You can use Use `is` to derive from another contract. check out solidity docs for more information on inheritance. here how your example code will look like

``````pragma solidity ^0.8.0;
``````

contract A {

``````address systemAddress = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2;

constructor(){

}

function funcA(address from) public view {
require(
"Invalid transaction source"
);
}
``````

}

contract B is A {

``````uint[] data;

constructor(){

data.push(10);
}

modifier fromSystem() {
require(
);
_;
}

function funcB() public view fromSystem returns (uint256){
// do something
return data;
}
``````

}

contract C is A, B{

``````constructor(){

}

function funcC() view public fromSystem returns (uint256) {
uint num = B.funcB();
return num;
}
``````

}