Created
January 3, 2019 05:52
-
-
Save iisaint/b5960c81b5039d9322b7fc300dd95398 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.22 <0.6.0; | |
// THIS CONTRACT CONTAINS A BUG - DO NOT USE | |
contract EtherDice { | |
event LOG_RESULT(uint _number, uint _dice, address _winner); | |
constructor() public payable { | |
require(msg.value > 0.1 ether); | |
} | |
function roll() public view returns(uint) { | |
return (block.timestamp % 6); | |
} | |
function bet(uint _number) public payable returns(bool) { | |
require(_number >=0 && _number <=5, "_number is between 0 to 5"); | |
uint _dice = roll(); | |
if (_number == _dice) { | |
msg.sender.transfer(msg.value*2); | |
emit LOG_RESULT(_number, _dice, msg.sender); | |
return true; | |
} | |
emit LOG_RESULT(_number, _dice, address(0x0)); | |
return false; | |
} | |
function getPool() public view returns(uint) { | |
return address(this).balance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment