contract HSendBatchTokens {
    
    mapping (address => mapping (address => bool)) private wasAirdropped;

    /*
     * CORE FUNCTIONS
     */
    /// @dev Allows sending 1 ERC20 standard token with 18 decimals to a group of accounts.
    /// @param _targets Array of target addresses.
    /// @param _token Address of the target token.
    /// @return Bool the transaction was successful.
    function sendBatchTokens(
        address[] calldata _targets,
        address _token)
        external
        returns (bool success)
    {
        uint256 length = _targets.length;
        uint256 amount = 1 * 10 ** 18;
        Token token = Token(_token);
        require(
            token.transferFrom(
                msg.sender,
                address(this),
                (amount * length)
            )
        );
        for (uint256 i = 0; i < length; i++) {
            if (token.balanceOf(_targets[i]) > uint256(0)) continue;
            if(wasAirdropped[_token][_targets[i]]) continue;
            wasAirdropped[_token][_targets[i]] = true;
            require(
                token.transfer(
                    _targets[i],
                    amount
                )
            );
        }
        if (token.balanceOf(address(this)) > uint256(0)) {
            require(
                token.transfer(
                    msg.sender,
                    token.balanceOf(address(this))
                )
            );
        }
        success = true;
    }
    
    /*
     * EXTERNAL VIEW FUNCTIONS
     */
    /// @dev Returns wether an account has been airdropped a specific token.
    /// @param _token Address of the target token.
    /// @param _target Address of the target holder.
    /// @return Bool the transaction was successful.
    function hasReceivedAirdrop(
        address _token,
        address _target)
        external
        view
        returns (bool)
    {
        return wasAirdropped[_token][_target];
    }
}
// solhint-disable-next-line
function sendBatchTokens(
    address[] calldata _targets,
    address _token)
    external
    returns (bool success)
{
    uint256 length = _targets.length;
    uint256 amount = 1 * 10 ** 18;
    Token token = Token(_token);
    require(
        token.transferFrom(
            msg.sender,
            address(this),
            (amount * length)
        )
    );
    for (uint256 i = 0; i < length; i++) {
        if (token.balanceOf(_targets[i]) > uint256(0)) continue;
        if(wasAirdropped[_token][_targets[i]]) continue;
        wasAirdropped[_token][_targets[i]] = true;
        require(
            token.transfer(
                _targets[i],
                amount
            )
        );
    }
    if (token.balanceOf(address(this)) > uint256(0)) {
        require(
            token.transfer(
                msg.sender,
                token.balanceOf(address(this))
            )
        );
    }
    success = true;
}

/// @dev Allows sending 1 ERC20 standard token with 18 decimals to a group of accounts.
/// @param _targets Array of target addresses.
/// @param _token Address of the target token.
/// @return Bool the transaction was successful.