chapter27-code-1

PHOTO EMBED

Thu Mar 30 2023 11:42:56 GMT+0000 (Coordinated Universal Time)

Saved by @RareSkills

contract Ownable {

	address public owner;

	constructor() {
		owner = msg.sender;
	}

	modifier onlyOwner() {
		require(msg.sender == owner, "onlyOwner");
		_;
	}

	function changeOwner(address newOwner) public onlyOwner {
		owner = newOwner;
	}

}

contract HoldFunds is Ownable {
	
	function withdrawFunds() public onlyOwner {
		(bool ok, ) = owner.call{value: address(this).balance}("");
		require(ok, "transfer failed");
	}

	receive() external payable {

	}
}
content_copyCOPY