Skip to content

Instantly share code, notes, and snippets.

@AlwaysBCoding
Last active August 12, 2018 07:33
Show Gist options
  • Save AlwaysBCoding/98689461c5f91751b980355876c76e69 to your computer and use it in GitHub Desktop.
Save AlwaysBCoding/98689461c5f91751b980355876c76e69 to your computer and use it in GitHub Desktop.
Ethereum Ðapp Development - Video 8 | Smart Contracts - Escrow
// package.json
{
"dependencies": {
"web3": "0.17.0-alpha",
"solc": "^0.4.4"
}
}
// Escrow.sol
contract Escrow {
address public buyer;
address public seller;
address public arbiter;
function Escrow(address _seller, address _arbiter) {
buyer = msg.sender;
seller = _seller;
arbiter = _arbiter;
}
function payoutToSeller() {
if(msg.sender == buyer || msg.sender == arbiter) {
seller.send(this.balance);
}
}
function refundToBuyer() {
if(msg.sender == seller || msg.sender == arbiter) {
buyer.send(this.balance);
}
}
function getBalance() constant returns (uint) {
return this.balance;
}
}
@NathanMaton
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment