Skip to content

Commit

Permalink
add external random number
Browse files Browse the repository at this point in the history
  • Loading branch information
pancake-swap committed Oct 27, 2020
1 parent af44ed5 commit a17409b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions contracts/Lottery.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ contract Lottery is LotteryOwnable, Initializable {
emit Reset(issueIndex);
}

function drawing() external onlyAdmin {
function drawing(uint256 _externalRandomNumber) external onlyAdmin {
require(!drawed(), "reset?");
bytes32 _structHash;
uint256 _randomNumber;
Expand All @@ -119,7 +119,8 @@ contract Lottery is LotteryOwnable, Initializable {
_structHash = keccak256(
abi.encode(
_blockhash,
totalAddresses
totalAddresses,
_externalRandomNumber
)
);
_randomNumber = uint256(_structHash);
Expand All @@ -130,7 +131,8 @@ contract Lottery is LotteryOwnable, Initializable {
_structHash = keccak256(
abi.encode(
_blockhash,
totalAmount
totalAmount,
_externalRandomNumber
)
);
_randomNumber = uint256(_structHash);
Expand All @@ -141,7 +143,8 @@ contract Lottery is LotteryOwnable, Initializable {
_structHash = keccak256(
abi.encode(
_blockhash,
lastTimestamp
lastTimestamp,
_externalRandomNumber
)
);
_randomNumber = uint256(_structHash);
Expand All @@ -152,7 +155,8 @@ contract Lottery is LotteryOwnable, Initializable {
_structHash = keccak256(
abi.encode(
_blockhash,
block.difficulty
block.difficulty,
_externalRandomNumber
)
);
_randomNumber = uint256(_structHash);
Expand Down

0 comments on commit a17409b

Please sign in to comment.