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
The current version of Solidity requires you to put a
payable
flag at the end of a constructor. If you don't do this, you'll getError: Cannot send value to non-payable function
Here's the corrected code: