-
-
Save hydai/be2e42877efc29b6d9536ef28a87ee8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity >=0.4.22 <0.8.0; | |
contract PiggyBank { | |
uint public goal; | |
constructor(uint _goal) { | |
goal = _goal; | |
} | |
receive() external payable {} | |
function getMyBalance() public view returns (uint) { | |
return address(this).balance; | |
} | |
function withdraw() public { | |
if (getMyBalance() > goal) { | |
selfdestruct(msg.sender); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment