Created
October 12, 2018 19:32
-
-
Save stupeters187/6b9d00125aa470075d3102c72eab6738 to your computer and use it in GitHub Desktop.
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
pragma solidity ^0.4.25; | |
contract Escrow { | |
address public buyer; | |
address public seller; | |
address public arbiter; | |
uint256 public escrowAmount; | |
constructor(address _buyer, address _arbiter, uint256 _escrowAmount) public { | |
seller = msg.sender; | |
buyer = _buyer; | |
arbiter = _arbiter; | |
escrowAmount = _escrowAmount; | |
} | |
function fund() payable public { | |
require(msg.value == escrowAmount); | |
} | |
function payoutSeller() public { | |
require(msg.sender == buyer || msg.sender == arbiter); | |
seller.transfer(address(this).balance); | |
} | |
function refundBuyer() public { | |
require(msg.sender == seller || msg.sender == arbiter); | |
buyer.transfer(address(this).balance); | |
} | |
function contractBalance() public view returns (uint256){ | |
return address(this).balance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment