Hi @Filip_Rucka,
Youâre nearly there with this ⌠but first there are some important issues you need to fix âŚ
(1)âIf you pass owner
to selfdestruct() then you are right to declare it as a state variable with a payable address-type. However, it is the owner
variable in Ownable which is assigned the contract ownerâs address when Bank is deployed, and not the other owner
variable youâve declared in Destroyable. If you add a getter to Destroyable to return owner
, you will see that it holds a zero address and not the contract ownerâs address. This means that when selfdestruct is triggered and the contract is destroyed, the remaining ether balance will be transferred to the zero address and lost, and not to the contract ownerâs address. You can remove this additional owner
variable from Destroyable, because it is redundant.
(2)âYouâve given the owner
variable in Ownable, which stores the contract ownerâs address, private visibility. This means that it isnât available in Destroyable. If you give it internal
or public
visibility, instead, it will be inherited by Destroyable and youâll be able to pass it to selfDestruct() as a payable address, so that the remaining ether balance held in the contract address will be transferred to the contract ownerâs external wallet address when the contract is destroyed.
(3)âThe onlyOwner modifier declared in Ownable is inherited by Destroyable, but youâre not using it to restrict access to the close() function to the contract owner, so that only the contract owner can trigger selfdestruct() and destroy the contract. Youâll see that, at the moment, any address can destroy the contract!
Can we also see what modifications youâve made to the start of your Bank.sol file, and Bank contract header, for the inheritance? After all, Bank is the derived contract that we are actually deploying.
Let me know if you need any help to make these modifications, or if you have any questions 