Created
March 26, 2019 15:36
-
-
Save etienne-napoleone/550ac133244ccc156821984a45fe7ce7 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.7+commit.6da8b019.js&optimize=false&gist=
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.5.5; | |
| import "github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol"; | |
| import "github.com/OpenZeppelin/zeppelin-solidity/contracts/ownership/Ownable.sol"; | |
| /** | |
| * @title Futo 封筒 | |
| * @dev Futo main smart contract | |
| */ | |
| contract Futo is Ownable { | |
| using SafeMath for uint256; | |
| uint256 private minBet; | |
| uint256 private betStep; | |
| uint256 private houseEdge; | |
| /** | |
| * @dev Constructor | |
| */ | |
| constructor (uint256 _minBet, uint256 _betStep, uint256 _houseEdge) public payable { | |
| minBet = _minBet; | |
| betStep = _betStep; | |
| houseEdge = _houseEdge; | |
| } | |
| } |
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.5.5; | |
| import "github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol"; | |
| import "github.com/OpenZeppelin/zeppelin-solidity/contracts/ownership/Ownable.sol"; | |
| /** | |
| * @title Hanhan 半々 | |
| * @dev Hanhan main smart contract | |
| */ | |
| contract Hanhan is Ownable { | |
| using SafeMath for uint256; | |
| uint256 private minBet; | |
| uint256 private maxBet; | |
| uint256 private bankrollSecurityThreshold; | |
| uint256 private maxBankroll; | |
| uint256 private houseEdge; | |
| /** | |
| * @dev Constructor | |
| */ | |
| constructor ( | |
| uint256 _minBet, | |
| uint256 _maxBet, | |
| uint256 _bankrollSecurityThreshold, | |
| uint256 _maxBankroll, | |
| uint256 _houseEdge | |
| ) public payable { | |
| minBet = _minBet; | |
| maxBet = _maxBet; | |
| bankrollSecurityThreshold = _bankrollSecurityThreshold; | |
| maxBankroll = _maxBankroll; | |
| houseEdge = _houseEdge; | |
| } | |
| /** | |
| * @dev payable fallback | |
| */ | |
| function () external payable { | |
| } | |
| function bet() external payable { | |
| require(msg.value>minBet); | |
| require(msg.value<maxBet); | |
| require(msg.value<(address(this).balance*bankrollSecurityThreshold)/100); | |
| bool result = true; //TODO result = call PRNG function, not 0 ... | |
| if(result) { | |
| msg.sender.transfer(msg.value*2); | |
| } | |
| } | |
| } |
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.5.5; | |
| import "github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol"; | |
| import "github.com/OpenZeppelin/zeppelin-solidity/contracts/ownership/Ownable.sol"; | |
| /** | |
| * @title Konki 根気 | |
| * @dev Konki main smart contract | |
| */ | |
| contract Konki { | |
| using SafeMath for uint256; | |
| struct Game { | |
| uint256 end; | |
| address[] biders; | |
| } | |
| address private _owner; | |
| uint256 private _timeout; | |
| uint256 private _bidSize; | |
| Game[] private _games; | |
| /** | |
| * @dev Constructor | |
| */ | |
| constructor (uint256 timeout, uint256 bidSize) public payable { | |
| _owner = msg.sender; | |
| _timeout = timeout; | |
| _bidSize = bidSize; | |
| } | |
| /** | |
| * @return the contract owner. | |
| */ | |
| function owner() public view returns (address) { | |
| return _owner; | |
| } | |
| /** | |
| * @return the bid size. | |
| */ | |
| function bidSize() public view returns (uint256) { | |
| return _bidSize; | |
| } | |
| /** | |
| * @return a game end time. | |
| */ | |
| function gameEnd() public view returns (uint256) { | |
| require(_games.length > 0); | |
| return _games[_games.length - 1].end; | |
| } | |
| /** | |
| * @return the last bider | |
| */ | |
| function lastBider() public view returns (address) { | |
| require(_games.length > 0); | |
| Game memory game = _games[_games.length - 1]; | |
| return game.biders[game.biders.length - 1]; | |
| } | |
| /** | |
| * @return current pot | |
| */ | |
| function pot() public view returns (uint256){ | |
| require(_games.length > 0); | |
| return address(this).balance; | |
| } | |
| /** | |
| * @dev Init the first game | |
| */ | |
| function init() public { | |
| require(msg.sender == _owner); | |
| require(_games.length == 0); | |
| _games.push(Game(now + _timeout, new address[](0))); | |
| _games[_games.length - 1].biders.push(msg.sender); | |
| } | |
| /** | |
| * @dev bid function | |
| */ | |
| function bid() external payable { | |
| require(_games.length > 0); | |
| require(msg.value == _bidSize); | |
| _games[_games.length - 1].biders.push(msg.sender); | |
| _games[_games.length - 1].end = now + _timeout; | |
| } | |
| /** | |
| * @dev whithdraw function for the winnar!!! | |
| */ | |
| function whithdraw() external { | |
| require(_games.length > 0); | |
| require(now > gameEnd()); | |
| require(msg.sender == lastBider()); | |
| _games[_games.length - 1].biders.push(msg.sender); | |
| _games[_games.length - 1].end = now + _timeout; | |
| } | |
| } |
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.5.7; | |
| import "github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol"; | |
| import "github.com/OpenZeppelin/zeppelin-solidity/contracts/ownership/Ownable.sol"; | |
| /** | |
| * @title Toru 取る | |
| * @dev Toru main smart contract | |
| */ | |
| contract Toru is Ownable { | |
| using SafeMath for uint; | |
| struct Round { | |
| uint256 id; | |
| uint256 endTime; | |
| uint256 betCount; | |
| address activePlayer; | |
| mapping (address => uint) playerBetCounts; | |
| } | |
| uint256 public minBet; | |
| uint256 public maxBet; | |
| uint256 public minTimeout; | |
| uint256 public maxTimeout; | |
| uint256 public nextGameEdgeNumerator; | |
| uint256 public nextGameEdgeDenominator; | |
| uint256 public houseEdgeNumerator; | |
| uint256 public houseEdgeDenominator; | |
| uint256 public roundId; | |
| mapping (uint256 => Round) public Rounds; | |
| event LogBet(address _activePlayer, uint256 _amount); | |
| event LogWithdraw(address _recipient, uint256 _amount); | |
| /** | |
| * @dev Constructor | |
| */ | |
| constructor ( | |
| uint256 _minBet, | |
| uint256 _maxBet, | |
| uint256 _minTimeout, | |
| uint256 _maxTimeout, | |
| uint256 _nextGameEdgeNumerator, | |
| uint256 _nextGameEdgeDenominator, | |
| uint256 _houseEdgeNumerator, | |
| uint256 _houseEdgeDenominator | |
| ) public payable { | |
| minBet = _minBet; | |
| maxBet = _maxBet; | |
| minTimeout = _minTimeout; | |
| maxTimeout = _maxTimeout; | |
| nextGameEdgeNumerator = _nextGameEdgeNumerator; | |
| nextGameEdgeDenominator = _nextGameEdgeDenominator; | |
| houseEdgeNumerator = _houseEdgeNumerator; | |
| houseEdgeDenominator = _houseEdgeDenominator; | |
| //init round | |
| Rounds[roundId].id = roundId; | |
| } | |
| /** | |
| * @dev payable fallback | |
| */ | |
| function () external payable { | |
| require(msg.sender == owner()); | |
| } | |
| function bet() external payable { | |
| require(msg.value > minBet); | |
| require(msg.value < maxBet); | |
| //refactor in "getTime()" | |
| //(((100 * (ammount - minBet)) / (maxBet - minBet)) * (maxTimeout - minTimeout) / 100) + minTimeout | |
| uint256 timout = ((msg.value.sub(minBet).div(maxBet.sub(minBet))).mul(maxTimeout.sub(minTimeout).div(100))).add(minTimeout); | |
| Rounds[roundId].endTime = now + timout; | |
| Rounds[roundId].betCount += 1; | |
| Rounds[roundId].activePlayer = msg.sender; | |
| Rounds[roundId].playerBetCounts[msg.sender] += 1; | |
| } | |
| function valueToTime(uint256 value) internal { | |
| time | |
| returns | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment