//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.18; contract CoinToss{ string public player1; string public player2; uint private tossDeadline; uint current; bool tossed; string result; event winner(string,string); function CoinToss(string _player1, string _player2){ player1=_player1; player2=_player2; tossDeadline= 6 seconds; tossed=false; } function Toss() public{ current = now; tossed=true; } function captureInputs(string _input1, string _input2) public{ getWinner(_input1, _input2); } function getWinner(string _input1,string _input2) returns(string){ uint _current=now; if((current-_current)%2==0){ result="heads"; } else{ result="tails"; } if(keccak256(result)==keccak256(_input1)){ winner("And the winner is:",player1); return "Winner is Player 1"; } else if(keccak256(result)==keccak256(_input2)){ winner("And the winner is:",player2); return "Winner is Player 2"; } } }
0.4.18