Created
January 10, 2016 21:14
-
-
Save pelle/38cde143e314a91b8362 to your computer and use it in GitHub Desktop.
Simple Escrow with Agent
This file contains hidden or 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 Escrow { | |
address buyer; | |
address seller; | |
address agent; | |
function Escrow(address _agent, address _seller) { | |
// In this simple example, the person sending money is the buyer and sets up the initial contract | |
buyer = msg.sender; | |
agent = _agent; | |
seller = _seller; | |
} | |
function release() { | |
if (msg.sender == agent) | |
suicide(seller); // Send all funds to seller | |
else | |
throw; | |
} | |
function cancel() { | |
if (msg.sender == agent) | |
suicide(buyer); // Cancel escrow and return all funds to buyer | |
else | |
throw; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment