Last active
January 4, 2019 02:25
-
-
Save iisaint/1b15c831aa6601e5d0b539c2e4f87f08 to your computer and use it in GitHub Desktop.
Revisions
-
iisaint revised this gist
Jan 4, 2019 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ contract EtherDice { } function bet(uint _number) public payable returns(bool) { require(isHuman(msg.sender), "robot is not allowed!!"); require(_number >=0 && _number <=5, "_number is between 0 to 5"); uint _dice = roll(); @@ -32,9 +32,9 @@ contract EtherDice { return address(this).balance; } function isHuman(address addr) internal view returns (bool) { uint size; assembly { size := extcodesize(addr) } return size == 0; } } -
iisaint created this gist
Jan 4, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ 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(isContract(msg.sender) == false, "robot is not allowed!!"); 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; } function isContract(address addr) internal view returns (bool) { uint size; assembly { size := extcodesize(addr) } return size > 0; } }