work-sample/contracts/Airdrop.sol

27 lines
694 B
Solidity
Raw Normal View History

2022-11-09 07:19:59 -08:00
// SPDX-License-Identifier: MIT
pragma solidity =0.8.17;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Airdrop is Ownable {
address public token;
constructor(address _token) {
token = _token;
}
function airdropTokens(
address[] memory _recipients,
uint256[] memory amount
) external onlyOwner {
require(
_recipients.length == amount.length,
"Airdrop: Recipients and amount length mismatch"
);
for (uint256 i = 0; i < _recipients.length; i++) {
IERC20(token).transfer(_recipients[i], amount[i]);
}
}
}