Skip to content

Instantly share code, notes, and snippets.

@alexroan
Created July 1, 2020 09:52
Show Gist options
  • Save alexroan/5fb10df5f69e9bde8a3b91ae861f35a6 to your computer and use it in GitHub Desktop.
Save alexroan/5fb10df5f69e9bde8a3b91ae861f35a6 to your computer and use it in GitHub Desktop.
thechain.sol
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