summaryrefslogtreecommitdiff
path: root/Year_3/Blockchain/RandomMoney.sol
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-06-18 10:50:48 +0200
committerSanto Cariotti <santo@dcariotti.me>2022-06-18 10:50:48 +0200
commitcb01e33790daf484f2a09419812e7f415da0f92d (patch)
tree734da5ea87777e0e5948d2d57e0250e7bc9a454d /Year_3/Blockchain/RandomMoney.sol
parentd6fdeec63a01ba43c5468ecc7c77a37347b0c953 (diff)
Ignore blockchain
Diffstat (limited to 'Year_3/Blockchain/RandomMoney.sol')
-rw-r--r--Year_3/Blockchain/RandomMoney.sol43
1 files changed, 0 insertions, 43 deletions
diff --git a/Year_3/Blockchain/RandomMoney.sol b/Year_3/Blockchain/RandomMoney.sol
deleted file mode 100644
index 2a5def4..0000000
--- a/Year_3/Blockchain/RandomMoney.sol
+++ /dev/null
@@ -1,43 +0,0 @@
-// SPDX-License-Identifier: MIT
-
-pragma solidity >0.7 <0.9;
-
-contract RandomMoney {
- uint public total;
- uint public constant minFee = 10;
- mapping(address => uint) public amounts;
- address[] private members;
-
-
- function play() public payable returns (uint) {
- require(msg.value >= minFee, "Value is less than the required minimum");
-
-
- amounts[msg.sender] += msg.value;
-
- if (amounts[msg.sender] == msg.value) {
- members.push(msg.sender);
- }
-
- total += msg.value;
-
- return total;
- }
-
- function pay() public payable {
- address payable account = payable(randomAddress());
- account.transfer(total);
- total = 0;
- }
-
- function randomAddress() internal view returns (address) {
- uint8 num = uint8(
- uint256(
- keccak256(abi.encode(block.timestamp, block.difficulty))
- ) % members.length
- );
-
- return members[num];
- }
-}
-