Last active
October 10, 2018 20:41
-
-
Save micahriggan/d0ad3dffe497cbe25f5c4e5599ca4170 to your computer and use it in GitHub Desktop.
Send tokens or ether to many addresses
This file contains 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.4.24; | |
import "./IERC20.sol"; | |
contract TransferToMany { | |
address owner; | |
constructor() public { | |
owner = msg.sender; | |
} | |
modifier onlyOwner { | |
require(msg.sender == owner, 'Only owner can do this'); | |
_; | |
} | |
function sendTo(address recepient, uint amount, address token) internal onlyOwner { | |
if(token == 0x0) { | |
recepient.transfer(amount); | |
} else { | |
IERC20(token).transfer(recepient, amount); | |
} | |
} | |
function sendToMany(address[] recepients, uint[] amounts, address[] tokens) public payable onlyOwner { | |
require(recepients.length == amounts.length, "Must have amount per address"); | |
require(recepients.length == tokens.length, "Must have a token address per address"); | |
for(uint i = 0; i < recepients.length; i++) { | |
sendTo(recepients[i], amounts[i], tokens[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment