GambleMe

Loading...
contract GambleMe{
    address owner;
    mapping (address => uint) winnings;
    uint minBet;
    uint divider = 65537;
    function GambleMe(){
      owner = msg.sender;
      minBet = 1000000000;
    }
    function Roll(uint lessThan) returns (bool){
      if(msg.value>=minBet){
        uint winRoll = getWinningRoll(block.number);
        if(winRoll<lessThan){
          uint winAmount = msg.value*getWinningMultiplier(lessThan);
          msg.sender.send(winAmount);
          winnings[msg.sender]+=winAmount;
          return true;
        } else {
          winnings[msg.sender]-=msg.value;
          return false;
        }
      } else {
        if(msg.value>0)
        	msg.sender.send(msg.value);
        return false;
      }
    }
    function getWinningChance(uint val) returns (uint){
      return 100/getWinningMultiplier(val);
    }
    function getWinningMultiplier(uint val) returns (uint){
      return divider/val;
    }
    function getWinningRoll(uint blockNum) returns(uint){
      uint256 hashVal = uint256(block.blockhash(blockNum));
      return hashVal%divider;
    }
  	function getOverallWinningAmount() returns (uint){
    	return winnings[msg.sender];
    }
}

Solidity contract for Ethereum

My Solidity code description.

Preferences

Note: Your changes won't be saved, because not Logged-in.

Create your own Contract