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
// Hash algorithm is Keccak256 | |
// The raw values are 'rock', 'scissors' and 'paper' | |
var hashOfRock = '10977e4d68108d418408bc9310b60fc6d0a750c63ccef42cfb0ead23ab73d102'; | |
var hashOfScissors = '389a2d4e358d901bfdf22245f32b4b0a401cc16a4b92155a2ee5da98273dad9a'; | |
var hashOfPaper = 'ea923ca2cdda6b54f4fb2bf6a063e5a59a6369ca4c4ae2c4ce02a147b3036a21'; |
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
function approvePoL(address _owner, uint _value) | |
private | |
returns (bool) | |
{ | |
address _receiver = getPoL[_owner].receiver; | |
bool _success = _receiver.send(_value); | |
return _success; | |
} |
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
function() payable { | |
address _owner = msg.sender; | |
uint _value = msg.value; | |
require(_value > 0); | |
require(isValidPoL(_owner)); | |
bool _success = approvePoL(_owner, _value); | |
if (_success) { |
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
function rejectPoL() | |
public | |
{ | |
address _owner = msg.sender; | |
require(existedPoL(_owner)); | |
uint _value = getPoL[_owner].deposit; | |
bool _success = _owner.send(_value); | |
if (_success) { | |
getPoL[_owner].receiver = address(0); |
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
function recoverBalance(address _owner) | |
public | |
payable | |
{ | |
require(msg.value > 0); | |
require(!existedPoL(_owner)); | |
address _receiver = msg.sender; | |
getPoL[_owner].receiver = _receiver; | |
getPoL[_owner].initialBlockNumber = block.number; |
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.17; | |
contract PoL { | |
// Declare variables, structures, mapping functions, events | |
struct pol { | |
address receiver; | |
uint initialBlockNumber; | |
uint deposit; | |
} |
NewerOlder