Created
January 17, 2018 19:14
-
-
Save joeb000/1bb7275b280fc985279616f5abee85d3 to your computer and use it in GitHub Desktop.
Friends Smart contract
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
contract Friends { | |
address public owner; | |
mapping (address => Friend) public friends; | |
uint defaultPayout = .1 ether; | |
struct Friend { | |
bool isFriend; | |
bool hasWithdrawn; | |
} | |
modifier onlyOwner { | |
require(msg.sender==owner); | |
_; | |
} | |
function Friends() { | |
owner = msg.sender; | |
} | |
function deposit() payable { | |
} | |
function addFriend(address _f) onlyOwner { | |
friends[_f].isFriend = true; | |
} | |
function withdraw() { | |
require (friends[msg.sender].isFriend && !friends[msg.sender].hasWithdrawn); | |
friends[msg.sender].hasWithdrawn = true; | |
msg.sender.send(defaultPayout); | |
} | |
function ownerWithdrawAll() onlyOwner { | |
owner.send(this.balance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment