helloWorld.sol
> pragma solidity 0.7.5;
>
> import "./Ownable.sol";
>
> import "./destroyable.sol";
>
> contract Bankkakount is Ownable, destroyable{
Ownable.sol
> contract Ownable {
>
> address payable public owner;
>
> constructor(){
>
> owner = msg.sender;
>
> }
>
> modifier Onlyowner{
>
> require(msg.sender == owner,"only the owner");
>
> _;
>
> }
>
> }
destroyable.sol
> import "./Ownable.sol";
>
> contract destroyable is Ownable{
>
> function DestroySC() public Onlyowner{
>
> selfdestruct(owner);
>
> }
>
> }
It seems to work well,
I have a question about the architecture,Im confuse because I didn’t find a match with the article about inheritance topic like this
Because
Ownable.sol was called at 2 times, so I changed the code like this, Is it better ?
destroyable.sol
> import "./Ownable.sol";
>
> contract destroyable is Ownable{
>
> function DestroySC() public Onlyowner{
>
> selfdestruct(owner);
>
> }
>
> }
helloWorld.sol
> pragma solidity 0.7.5;
>
>
> import "./destroyable.sol";
>
> contract Bankkakount is destroyable{
Ownable.sol
> contract Ownable {
>
> address payable public owner;
>
> constructor(){
>
> owner = msg.sender;
>
> }
>
> modifier Onlyowner{
>
> require(msg.sender == owner,"only the owner");
>
> _;
> }
>
> }
Like this we can imagine that helloWorld.sol is the parent of destroyable.sol who is at the same time the parent of Ownable.sol , so helloWorld.sol can also acces to Ownable.sol by destroyable.sol right ?
But the point is if I let the code like this ,If I don’t use destroyable.sol and don’t import on the main contrat I will not get access to Ownable.sol and That’s a problem…
Let me know what you think about that , thank’s in advance team !