Skip to content

Instantly share code, notes, and snippets.

@casweeney
Created August 30, 2022 00:07
Show Gist options
  • Select an option

  • Save casweeney/e39e8e48678c4bc65a4ec1dc03806b88 to your computer and use it in GitHub Desktop.

Select an option

Save casweeney/e39e8e48678c4bc65a4ec1dc03806b88 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract Multisend {
address owner;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "only owner required");
_;
}
function sendToMany(address[] memory receivers, uint _amount) external onlyOwner {
require(receivers.length > 0, "can't send money to no one");
uint totalAmount = _amount * receivers.length;
require(address(this).balance > totalAmount, "insufficient fund for disbursement");
for(uint i = 0; i < receivers.length; i++) {
payable(receivers[i]).transfer(_amount);
}
}
function deposit() external payable {
require(msg.value > 0, "can't send zero value");
}
function getContractBalance() external view returns (uint bal) {
bal = address(this).balance;
}
function withdraw(uint _amount) external onlyOwner {
require(address(this).balance > _amount, "insufficient fund");
payable(msg.sender).transfer(_amount);
}
receive() external payable {}
fallback() external payable {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment