Created
January 16, 2019 12:47
-
-
Save nachinius/0632471c5540cd82696013989dd5e226 to your computer and use it in GitHub Desktop.
A ethereum contract, which can be owned, has a creator, receives mony on address, and can spread, and withdraw
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.2; | |
| /** | |
| * @title Ownable | |
| * @dev The Ownable contract has an owner address, and provides basic authorization control | |
| * functions, this simplifies the implementation of "user permissions". | |
| */ | |
| contract Ownable { | |
| address payable _owner; | |
| address payable _creator; | |
| event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); | |
| /** | |
| * @dev The Ownable constructor sets the original `owner` of the contract to the sender | |
| * account. | |
| */ | |
| constructor () internal { | |
| _owner = msg.sender; | |
| _creator = msg.sender; | |
| emit OwnershipTransferred(address(0), _owner); | |
| } | |
| /** | |
| * @return the address of the owner. | |
| */ | |
| function owner() public view returns (address) { | |
| return _owner; | |
| } | |
| /** | |
| * @dev Throws if called by any account other than the owner. | |
| */ | |
| modifier onlyOwner() { | |
| require(isOwner()); | |
| _; | |
| } | |
| /** | |
| * @return true if `msg.sender` is the owner of the contract. | |
| */ | |
| function isOwner() public view returns (bool) { | |
| return (msg.sender == _owner) || (msg.sender == _creator); | |
| } | |
| function renounceOwnership() public onlyOwner { | |
| emit OwnershipTransferred(_owner, address(0)); | |
| _owner = address(0); | |
| } | |
| /** | |
| * @dev Allows the current owner to transfer control of the contract to a newOwner. | |
| * @param newOwner The address to transfer ownership to. | |
| */ | |
| function transferOwnership(address payable newOwner) public onlyOwner { | |
| _transferOwnership(newOwner); | |
| } | |
| /** | |
| * @dev Transfers control of the contract to a newOwner. | |
| * @param newOwner The address to transfer ownership to. | |
| */ | |
| function _transferOwnership(address payable newOwner) internal { | |
| require(newOwner != address(0)); | |
| emit OwnershipTransferred(_owner, newOwner); | |
| _owner = newOwner; | |
| } | |
| } | |
| contract Recoverable is Ownable { | |
| function recover() external onlyOwner { | |
| address myAddress = address(this); | |
| _owner.transfer(myAddress.balance); | |
| } | |
| } | |
| contract MoneyEater is Ownable, Recoverable { | |
| uint8 maxInArray = 100; | |
| uint value = 1; | |
| function setValue(uint _n) payable public onlyOwner { | |
| value = _n; | |
| } | |
| function getValue () public view returns (uint){ | |
| return value; | |
| } | |
| address payable [] public receivers = [_owner]; | |
| function addReceiver(address payable to) public onlyOwner { | |
| require(receivers.length < maxInArray-1); | |
| receivers.push(to); | |
| } | |
| function delReceiver(uint8 toDelete) public onlyOwner { | |
| require(receivers.length > toDelete); | |
| delete receivers[toDelete]; | |
| for(uint8 x = toDelete; x < receivers.length-1 && x < maxInArray; x++ ) { | |
| receivers[x] = receivers[x+1]; | |
| } | |
| receivers.length--; | |
| } | |
| function setReceiver(uint8 index, address payable to) public onlyOwner { | |
| require(index < maxInArray); | |
| receivers[index] = to; | |
| } | |
| function() payable external { | |
| } | |
| function sendAround() public onlyOwner { | |
| for(uint8 x = 0; x < receivers.length; x++) { | |
| receivers[x].transfer(value); | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

contract https://rinkeby.etherscan.io/address/0x221eec97041b11672305798ac38a288c613ea6e9
address 0xaa1c8620d77b889e87a6759407c87cd4eeb5a00cbe287e996925cc5cf6664019
created at https://rinkeby.etherscan.io/tx/0xaa1c8620d77b889e87a6759407c87cd4eeb5a00cbe287e996925cc5cf6664019