File size: 1,080 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

interface IERC20 {
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

contract BatchTransferGasFee {
    function batchTransferToken(
        address token,
        uint256 amount,
        address[] memory _accounts
    ) public {
        for (uint256 index = 0; index < _accounts.length; index++) {
            IERC20(token).transferFrom(msg.sender, _accounts[index], amount);
        }
    }

    function batchTransferNative(uint256 _amount, address[] memory _accounts)
        public
        payable
    {
        require(msg.value != 0, "Insufficient");

        for (uint256 index = 0; index < _accounts.length; index++) {
            payable(_accounts[index]).transfer(_amount);
        }

        payable(msg.sender).transfer(address(this).balance);
    }
}