Skip to content

Commit

Permalink
Create lottery contract
Browse files Browse the repository at this point in the history
  • Loading branch information
boczeratul committed Apr 7, 2019
1 parent 8e3c854 commit 439d71e
Show file tree
Hide file tree
Showing 15 changed files with 2,542 additions and 4,095 deletions.
18 changes: 0 additions & 18 deletions contracts/DonationDXN.sol

This file was deleted.

140 changes: 0 additions & 140 deletions contracts/Election.sol

This file was deleted.

167 changes: 0 additions & 167 deletions contracts/ElectionPractice.sol

This file was deleted.

30 changes: 30 additions & 0 deletions contracts/Lottery.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pragma solidity ^0.5.2;

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";

contract Lottery is Ownable {
mapping (uint256 => uint256) public numberOfTime;
uint256[] public revealedTimes;
uint256 public revealedTimesCount = 0;
uint256 public lastRevealedTime;

event NumberRevealed(uint256 indexed timestamp, uint256 number, uint256 rawValue);

function reveal(uint256 timestamp) public onlyOwner {
// check if timestamp is in the future
// or if number of timestamp is already revealed
if (timestamp > now || numberOfTime[timestamp] != 0) {
revert();
}

uint256 rawValue = rand;
uint256 number = rawValue % 1000;

numberOfTime[timestamp] = number;
revealedTimes.push(timestamp);
revealedTimesCount++;
lastRevealedTime = timestamp;

emit NumberRevealed(timestamp, number, rawValue);
}
}
2 changes: 1 addition & 1 deletion contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.5.2;

contract Migrations {
address public owner;
Expand Down
20 changes: 0 additions & 20 deletions contracts/Security.sol

This file was deleted.

Loading

0 comments on commit 439d71e

Please sign in to comment.