Skip to content

Instantly share code, notes, and snippets.

@MrCrambo
Created May 20, 2018 23:57
Show Gist options
  • Save MrCrambo/e7256c17c9c174f3bb40f0ce82789f92 to your computer and use it in GitHub Desktop.
Save MrCrambo/e7256c17c9c174f3bb40f0ce82789f92 to your computer and use it in GitHub Desktop.
function batchTransfer(address[] _receivers, uint256 _value) public whenNotPaused returns (bool) {
uint cnt = _receivers.length;
uint256 amount = uint256(cnt) * _value;
require(cnt > 0 && cnt <= 20);
require(_value > 0 && balances[msg.sender] >= amount);
balances[msg.sender] = balances[msg.sender].sub(amount);
for (uint i = 0; i < cnt; i++) {
balances[_receivers[i]] = balances[_receivers[i]].add(_value);
Transfer(msg.sender, _receivers[i], _value);
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment