Skip to content

Instantly share code, notes, and snippets.

@saintbyte saintbyte/test3.sol
Created Jul 8, 2018

Embed
What would you like to do?
pragma solidity ^0.4.24;
contract Test3
{
address public owner;
mapping(address => uint) private holders;
address[] holders_addrs;
uint256 totalWei;
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
constructor() public {
totalWei = 0;
}
function buy() public payable {
if (holders[msg.sender] > 0)
{
holders[msg.sender] = holders[msg.sender] + msg.value;
} else {
holders[msg.sender] = msg.value;
holders_addrs.push(msg.sender);
}
totalWei = totalWei + msg.value;
}
function sendHalf() public onlyOwner payable
{
for(uint i = 0; i < holders_addrs.length ; i++){
holders_addrs[i].transfer(holders[holders_addrs[i]] / 2);
}
totalWei = totalWei / 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.