Last active
August 12, 2018 07:33
-
-
Save AlwaysBCoding/98689461c5f91751b980355876c76e69 to your computer and use it in GitHub Desktop.
Ethereum Ðapp Development - Video 8 | Smart Contracts - Escrow
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
// 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Extended gist notes here: https://gist.github.com/NathanMaton/e4d812a318a9383ee918b35efc7f6083