Skip to content

Instantly share code, notes, and snippets.

@maymax777
Created February 8, 2022 12:47
Show Gist options
  • Save maymax777/a2f9c7ae44d6c76eaac1eb7cd4fd9278 to your computer and use it in GitHub Desktop.
Save maymax777/a2f9c7ae44d6c76eaac1eb7cd4fd9278 to your computer and use it in GitHub Desktop.
contract Multisend {
function multisendEther(address[] memory recipients, uint256[] memory values)
external
payable
{
for (uint256 i = 0; i < recipients.length; i++)
payable(recipients[i]).transfer(values[i]);
uint256 balance = address(this).balance;
if (balance > 0) payable(msg.sender).transfer(balance);
}
function multisendToken(
IERC20 token,
address[] memory recipients,
uint256[] memory values
) external {
uint256 total = 0;
for (uint256 i = 0; i < recipients.length; i++) total += values[i];
require(token.transferFrom(msg.sender, address(this), total));
for (uint256 i = 0; i < recipients.length; i++)
require(token.transfer(recipients[i], values[i]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment