Created
July 1, 2020 09:52
-
-
Save alexroan/5fb10df5f69e9bde8a3b91ae861f35a6 to your computer and use it in GitHub Desktop.
thechain.sol
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.0; | |
import "@openzeppelin/contracts/math/SafeMath.sol"; | |
contract Doubler { | |
using SafeMath for uint; | |
address payable public owner; | |
struct User { | |
address payable addr; | |
uint amount; | |
} | |
User[] public users; | |
uint public currentlyPaying = 0; | |
uint public totalUsers = 0; | |
constructor() public { | |
owner = msg.sender; | |
} | |
function join() external payable{ | |
users.push(User(msg.sender, msg.value)); | |
totalUsers += 1; | |
owner.transfer(msg.value.div(10)); | |
while (address(this).balance > users[currentlyPaying].amount.mul(2)) { | |
users[currentlyPaying].addr.transfer(users[currentlyPaying].amount.mul(2)); | |
currentlyPaying += 1; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment