pragma solidity ^0.4.25; contract SportBetting { //Variables address public manager; address public bettorA; address public bettorB; address public winner; //constructor of the contract - the msg.sender is the address of the contract creator - in this function the creater will be the manager constructor() public { manager = msg.sender; } //modifier require only the mmanager have the right to call this function modifier onlyManager() { require(msg.sender == manager); _; } //modifier require only the bettor have the right to call this function modifier onlyBettor() { require(msg.sender == bettorA | msg.sender == bettorB); _; } //Bettor join to A side and sending money to winning pool function enterA() public payable { bettorA.push(msg.sender); } //Bettor join to B side and sending money to winning pool function enterB() public payable { bettor.push(msg.sender); } //Function to get the winner name /* function random() private view returns (uint) { return uint(keccak256(abi.encodePacked(block.difficulty, now, bettors))); } */ //Function return the address of winner - This function only called only by manager function pickWinner() onlyManager returns (address) { //uint index = random() % bettors.length; winner = enterWinner(); winner.transfer(address(this).balance); bettors = new address[](0); return winner; } function removeBet() onlyBettor returns() { } }
0.4.18