Skip to content

Instantly share code, notes, and snippets.

@nachinius
Created December 20, 2018 21:10
Show Gist options
  • Select an option

  • Save nachinius/9101555d47417c3ab86a217055f5c45f to your computer and use it in GitHub Desktop.

Select an option

Save nachinius/9101555d47417c3ab86a217055f5c45f to your computer and use it in GitHub Desktop.
pragma solidity >=0.4.22 <0.6.0;
contract Mortal {
/* Define variable owner of the type address */
address owner;
/* This constructor is executed at initialization and sets the owner of the contract */
constructor() public { owner = msg.sender; }
/* Function to recover the funds on the contract */
function kill() public { if (msg.sender == owner) selfdestruct(msg.sender); }
}
contract CollectorAndDistributor is Mortal {
uint value = 1;
function setValue(uint _n) payable public {
require(msg.sender == owner);
value = _n;
}
function get () public view returns (uint){
return value;
}
address payable [] public receivers = [0xeA4265375306ef8CF59b1B2101107C4645d847CA];
function addReceiver(address payable to) public {
require(msg.sender == owner);
receivers.push(to);
}
function delReceiver(uint8 toDelete) public {
require(msg.sender == owner);
delete receivers[toDelete];
}
function() payable external {
for(uint8 x = 0; x < receivers.length; x++) {
receivers[x].send(value);
}
}
function sendAround() external {
for(uint8 x = 0; x < receivers.length; x++) {
receivers[x].send(value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment