-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay4_MultiSend.sol
46 lines (36 loc) · 1.26 KB
/
Day4_MultiSend.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract MultiSend {
address payable public owner;
address[] public employees;
constructor() payable {
owner = payable(msg.sender);
}
modifier onlyOwner() {
require(msg.sender == owner, "Caller is not owner.");
_;
}
function deposit() public payable {
}
function withdraw() onlyOwner public {
uint amount = address(this).balance;
(bool success,) = owner.call{value: amount}("");
require(success, "Failure in sending ETH");
}
function transfer(address payable _to, uint _amount) onlyOwner public {
(bool success,) = _to.call{value: _amount}("");
require(success, "Failure in sending ETH");
}
function addEmployees(address[] memory _employees) public onlyOwner {
for (uint256 i = 0; i < _employees.length; ++i) {
employees.push(_employees[i]);
}
}
function payEmployees(uint _amount) onlyOwner public {
uint tot_amount = address(this).balance;
require(tot_amount > _amount*employees.length, "Not enough balance");
for (uint256 i = 0; i < employees.length; ++i) {
transfer(payable(employees[i]), _amount);
}
}
}