Created
August 30, 2022 00:07
-
-
Save casweeney/e39e8e48678c4bc65a4ec1dc03806b88 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // 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