pragma solidity ^0.4.17;
/**
* @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 public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @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 newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract iPromo {
function massNotify(address[] _owners) public;
function transferOwnership(address newOwner) public;
}
/**
* Distribute promo tokens parallel
* negligible, +3k gas cost / tx
* 500 address ~ 1.7M gas
* author: thesved, viktor.tabori at etheal dot com
*/
contract EthealPromoDistribute is Ownable {
mapping (address => bool) public admins;
iPromo public token;
// constructor
constructor(address _promo) public {
token = iPromo(_promo);
}
// set promo token
function setToken(address _promo) onlyOwner public {
token = iPromo(_promo);
}
// transfer ownership of token
function passToken(address _promo) onlyOwner public {
require(_promo != address(0));
require(address(token) != address(0));
token.transferOwnership(_promo);
}
// set admins
function setAdmin(address[] _admins, bool _v) onlyOwner public {
for (uint256 i = 0; i<_admins.length; i++) {
admins[ _admins[i] ] = _v;
}
}
// notify
function massNotify(address[] _owners) external {
require(admins[msg.sender] || msg.sender == owner);
token.massNotify(_owners);
}
}
{
"compilationTarget": {
"EthealPromoDistribute.sol": "EthealPromoDistribute"
},
"evmVersion": "byzantium",
"libraries": {},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"constant":false,"inputs":[{"name":"_owners","type":"address[]"}],"name":"massNotify","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_promo","type":"address"}],"name":"setToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_promo","type":"address"}],"name":"passToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"admins","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_admins","type":"address[]"},{"name":"_v","type":"bool"}],"name":"setAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_promo","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]