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

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract StonkAirdrop is Ownable {
  IERC20 public token;
  uint256 public airdropAmount;
  mapping(address => bool) public hasClaimed;

  event AirdropClaimed(address indexed recipient, uint256 amount);

  constructor(IERC20 _token, uint256 _airdropAmount) {
    token = _token;
    airdropAmount = _airdropAmount;
  }

  function claimAirdrop() external {
    require(!hasClaimed[msg.sender], "Airdrop: Already claimed");
    require(token.balanceOf(address(this)) >= airdropAmount, "Airdrop: Insufficient tokens");

    hasClaimed[msg.sender] = true;
    token.transfer(msg.sender, airdropAmount);

    emit AirdropClaimed(msg.sender, airdropAmount);
  }

  function updateAirdropAmount(uint256 _newAmount) external onlyOwner {
    airdropAmount = _newAmount;
  }

  function withdrawTokens(address _to, uint256 _amount) external onlyOwner {
    token.transfer(_to, _amount);
  }

  function withdrawETH(address payable _to, uint256 _amount) external onlyOwner {
    (bool success, ) = _to.call{value: _amount}("");
    require(success, "Airdrop: ETH withdrawal failed");
  }

  receive() external payable {}
}
[{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint256","name":"_airdropAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AirdropClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"airdropAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimAirdrop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"hasClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newAmount","type":"uint256"}],"name":"updateAirdropAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]