Created
March 4, 2018 20:22
-
-
Save anonymous/6b06bef626928589e3a53a70c021ec02 to your computer and use it in GitHub Desktop.
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.20+commit.3155dd80.js&optimize=false&gist=
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.10; | |
contract Ownable { | |
address owner; | |
function Ownable() public { | |
owner = msg.sender; | |
} | |
modifier Owned { | |
require(msg.sender == owner); | |
_; | |
} | |
} | |
contract Mortal is Ownable { | |
function kill() public Owned { | |
selfdestruct(owner); | |
} | |
} | |
contract Casino is Mortal{ | |
uint minBet; | |
uint houseEdge; //in % | |
event Won(bool _status, uint _amount); | |
function Casino(uint _minBet, uint _houseEdge) payable public { | |
require(_minBet > 0); | |
require(_houseEdge <= 100); | |
minBet = _minBet; | |
houseEdge = _houseEdge; | |
} | |
function() public { //fallback | |
revert(); | |
} | |
function bet(uint _number) payable public { | |
require(_number > 0 && _number <= 10); | |
require(msg.value >= minBet); | |
uint winningNumber = block.number % 10 + 1; | |
if (_number == winningNumber) { | |
uint amountWon = msg.value * (100 - houseEdge)/10; | |
if(!msg.sender.send(amountWon)) revert(); | |
Won(true, amountWon); | |
} else { | |
Won(false, 0); | |
} | |
} | |
function checkContractBalance() Owned public view returns(uint) { | |
return this.balance; | |
} | |
} |
zhengfen
commented
Jun 17, 2019
•
creation of Casino errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment