Skip to content

Instantly share code, notes, and snippets.

@fakenickels
Last active February 27, 2022 01:26
Show Gist options
  • Save fakenickels/3d5e453dc824e8ca8cc03d899fb119a8 to your computer and use it in GitHub Desktop.
Save fakenickels/3d5e453dc824e8ca8cc03d899fb119a8 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
interface KittensHD {
function getGeneralMintCounter() external returns (uint256);
function getPrice(uint256 quantity) external returns (uint256);
function unpauseMinting() external;
function pauseMinting() external;
function daoAnyClaim(uint256 quantity) external;
function safeTransferFrom(
address a,
address b,
uint256 tokenId
) external;
}
contract Airdrop is IERC721Receiver {
KittensHD public kittensHD;
address public owner;
constructor(address kittensHDAddress) {
owner = msg.sender;
kittensHD = KittensHD(kittensHDAddress);
}
function airdrop(address[] memory holders, uint256 amountEach) external {
require(msg.sender == owner, "not owner");
for (uint256 i = 0; i < holders.length; i++) {
if(!isContract(holders[i])) {
uint256 currentIndex = kittensHD.getGeneralMintCounter();
kittensHD.daoAnyClaim(amountEach);
for (uint256 j = 0; j < amountEach; j++) {
kittensHD.safeTransferFrom(address(this), holders[i], j + currentIndex);
}
}
}
}
function isContract(address addr) internal returns (bool) {
uint size;
assembly { size := extcodesize(addr) }
return size > 0;
}
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external override returns (bytes4) {
return this.onERC721Received.selector;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment