// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0 <0.9.0;
import "./library/Mintable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.6.0/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.6.0/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.6.0/contracts/token/ERC1155/extensions/ERC1155Pausable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.6.0/contracts/token/ERC721/IERC721.sol";
/**
* @title Airdrops
* @dev Extends ERC1155 , ERC1155Supply, ERC1155Burnable, ERC1155Pausable
* @author @FrankNFT.eth
*/
contract Airdrops is ERC1155Supply, ERC1155Burnable, Mintable {
mapping(uint256 => string) private tokenUri;
mapping(uint256 => bool) private saleIsActive;
mapping(uint256 => mapping(uint256 => bool)) tokenUsed;
IERC721 oneOnesContract;
string constant private _name="OneOnes BonusMints";
string constant private _symbol="OBM";
constructor() ERC1155("ipfs://") {
oneOnesContract = IERC721(0x2DE87C6F15BC8B3aF69443E5274302D02D55a38C);
}
/**
* @dev set contract
*/
function setContract(address token) external onlyOwner {
oneOnesContract = IERC721(token);
}
/**
* @dev mint a reserve
*/
function mintReserve(uint256 token, uint256 amount) external onlyMinter {
_mint(msg.sender, token, amount, "");
}
/**
* @dev airdrop a specific token to a list of addresses
*/
function airdrop(address[] calldata addresses, uint256 token, uint amt_each) external onlyMinter {
uint length = addresses.length;
for (uint i=0; i < length;) {
_mint(addresses[i], token, amt_each, "");
unchecked{ i++;}
}
}
/**
* @dev allows to mint a tokens to the wallet of the msg.sender if he holds OneOnes
*/
function mint(uint256 token, uint[] calldata tokenIds) external{
require(saleIsActive[token],"Sale NOT active");
uint length = tokenIds.length;
require(length != 0, "numberOfNfts cannot be 0");
uint amount;
for (uint i=0; i < length;) {
if (!tokenUsed[token][tokenIds[i]] && oneOnesContract.ownerOf(tokenIds[i])==msg.sender){
tokenUsed[token][tokenIds[i]]=true;
unchecked{ amount++;}
}
unchecked{ i++;}
}
require(amount != 0, "no Valid id's");
_mint(msg.sender, token, amount, "");
}
/**
* Pause sale if active, make active if paused for a specific token
*/
function flipSaleState(uint256 token) external onlyOwner {
saleIsActive[token] = !saleIsActive[token];
}
function isSaleActive(uint256 token) external view returns(bool){
return saleIsActive[token];
}
function oneOneUsed(uint256 oneOnetoken, uint256 token) external view returns(bool){
return tokenUsed[token][oneOnetoken];
}
/**
* @dev set token base uri
*/
function setURI(string memory baseURI) public onlyOwner {
_setURI(baseURI);
}
/**
* @dev set token hash
*/
function setTokenURI(uint256 token, string memory tokenURI) public onlyMinter {
tokenUri[token]=tokenURI;
}
/**
* @dev removing the token substituion and replacing it with the implementation of the ERC721
*/
function uri(uint256 token) public view virtual override returns (string memory) {
string memory baseURI = super.uri(token);
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenUri[token])) : "";
}
///////////// Add name and symbol for etherscan /////////////////
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
///////////// Overwrites /////////////
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override(ERC1155, ERC1155Supply) {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.6.0/contracts/access/Ownable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.6.0/contracts/utils/structs/EnumerableSet.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an minter) that can be granted exclusive access to
* specific functions.
*
* By default, the minter account will be the one that deploys the contract. This
* can later be changed with {setMinter}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyMinter`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Mintable is Ownable {
using EnumerableSet for EnumerableSet.AddressSet;
// Track registered minters
EnumerableSet.AddressSet private _minters;
/**
* @dev Initializes the contract setting the deployer as the initial minter.
*/
constructor() {
}
/**
* @dev Returns the address of the current minters.
*/
function getMinters() external view returns (address[] memory minters) {
minters = new address[](_minters.length());
for (uint i = 0; i < _minters.length(); i++) {
minters[i] = _minters.at(i);
}
return minters;
}
/**
* @dev Throws if called by any account other than the Minter.
*/
modifier onlyMinter() {
require(owner() == _msgSender() || _minters.contains(msg.sender), "Mintable: caller is not the owner or minter");
_;
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function addMinter(address newMinter) external virtual onlyOwner {
require(newMinter != address(0), "Mintable: new minter is the zero address.");
require(!_minters.contains(newMinter),"Mintable: Minter already exists.");
_addMinter(newMinter);
}
/**
* @dev Revoke a minter
*/
function revokeMinter(address minter) external onlyOwner {
if (_minters.contains(minter)) {
_minters.remove(minter);
}
}
function _addMinter(address newMinter) private {
_minters.add(newMinter);
}
}
{
"compilationTarget": {
"contracts/Airdrops.sol": "Airdrops"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 1000
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[{"internalType":"address","name":"newMinter","type":"address"}],"name":"addMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256","name":"token","type":"uint256"},{"internalType":"uint256","name":"amt_each","type":"uint256"}],"name":"airdrop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"burnBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"token","type":"uint256"}],"name":"flipSaleState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getMinters","outputs":[{"internalType":"address[]","name":"minters","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"token","type":"uint256"}],"name":"isSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"token","type":"uint256"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"token","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mintReserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"oneOnetoken","type":"uint256"},{"internalType":"uint256","name":"token","type":"uint256"}],"name":"oneOneUsed","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":[{"internalType":"address","name":"minter","type":"address"}],"name":"revokeMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"setContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"token","type":"uint256"},{"internalType":"string","name":"tokenURI","type":"string"}],"name":"setTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI","type":"string"}],"name":"setURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"token","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]