Hi,
can someone explain me why can't i call Kill contract from Helper contract if i set modifier and constructor to owner == msg.sender
in Kill contract ? When i try to call from Helper its reverting and saying im not the owner even though i call from owner address. When i call directly from Killcontract with the same address it's perfectly fine.
Code below:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Kill {
address public owner;
constructor() payable {
owner = msg.sender;
}
modifier onlyOwner {
require(owner == msg.sender, "You are not the owner");
_;
}
function kill() external onlyOwner {
selfdestruct(payable(msg.sender));
}
function testCall() external pure returns (uint) {
return 123;
}
}
contract Helper {
function getBalance() public view returns (uint) {
return address(this).balance;
}
function kill(Kill _kill) external {
_kill.kill();
}
}