Skip to content

Instantly share code, notes, and snippets.

@tim-cotten
Last active June 13, 2019 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-cotten/3fcd9a888e5fb370636a060bcde37370 to your computer and use it in GitHub Desktop.
Save tim-cotten/3fcd9a888e5fb370636a060bcde37370 to your computer and use it in GitHub Desktop.
Simple Deposit Account (v0.1.3 Don't Use - Intro Version for Safety Discussion)
pragma solidity >=0.4.22 <0.6.0;
contract DepositAccount {
address private owner;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier withMinBalance(uint256 amount) {
require(address(this).balance >= amount);
_;
}
constructor() public {
owner = msg.sender;
}
function withdraw() onlyOwner public {
msg.sender.transfer(address(this).balance);
}
function withdraw(uint256 amount) onlyOwner withMinBalance(amount) public {
msg.sender.transfer(amount);
}
function() payable external {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment