Last active
June 13, 2016 07:07
-
-
Save JeffreyBPetersen/da2a9793ff6ee6628f86be361d3b8c49 to your computer and use it in GitHub Desktop.
Buy a shirt off someone's back using Ethereum
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 BuyThisTshirt { | |
address currentOwner; | |
uint price; | |
bool forSale; | |
mapping (address => uint) payouts; | |
function BuyThisTshirt(){ | |
currentOwner = msg.sender; | |
forSale = true; | |
} | |
function buy(){ | |
if(msg.value < price) throw; | |
payouts[currentOwner] += msg.value; | |
currentOwner = msg.sender; | |
forSale = false; | |
} | |
function getPayout(){ | |
msg.sender.send(payouts[msg.sender]); | |
payouts[msg.sender] = 0; | |
} | |
function setPrice(uint howMuch){ | |
if(msg.sender != currentOwner) throw; | |
price = howMuch; | |
forSale = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment