Created
November 21, 2017 14:32
-
-
Save marekkirejczyk/4f0b14654bbd423fdb8e7fa208e18d29 to your computer and use it in GitHub Desktop.
TossCoin
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.18; | |
contract TossCoin { | |
address player1; | |
address player2; | |
address oracle; | |
uint value; | |
function TossCoin(address _oracle) payable public { | |
oracle = _oracle; | |
player1 = msg.sender; | |
value = msg.value; | |
} | |
function join() payable public { | |
require(msg.value == value); | |
require(player2 == 0x0); | |
player2 = msg.sender; | |
} | |
function settle(address winner) public { | |
require(msg.sender == oracle); | |
require(player1 == winner || player2 == winner); | |
winner.transfer(this.balance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment