// SPDX-License-Identifier: MITpragmasolidity ^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
*/contractAirdropsisERC1155Supply, ERC1155Burnable, Mintable{
mapping(uint256=>string) private tokenUri;
mapping(uint256=>bool) private saleIsActive;
mapping(uint256=>mapping(uint256=>bool)) tokenUsed;
IERC721 leaderContract;
stringconstantprivate _name="Kiki Exchange Center";
stringconstantprivate _symbol="KEC";
constructor() ERC1155("ipfs://") {
leaderContract = IERC721(0x2f5524b0973aEA012F9Afa0DF87d3b5BBA21130E);
}
/**
* @dev set contract
*/functionsetContract(address token) externalonlyOwner{
leaderContract = IERC721(token);
}
/**
* @dev mint a reserve
*/functionmintReserve(uint256 token, uint256 amount) externalonlyMinter{
_mint(msg.sender, token, amount, "");
}
/**
* @dev airdrop a specific token to a list of addresses
*/functionairdrop(address[] calldata addresses, uint256 token, uint amt_each) externalonlyMinter{
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
*/functionmint(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]] && leaderContract.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
*/functionflipSaleState(uint256 token) externalonlyOwner{
saleIsActive[token] =!saleIsActive[token];
}
functionisSaleActive(uint256 token) externalviewreturns(bool){
return saleIsActive[token];
}
functiononeOneUsed(uint256 oneOnetoken, uint256 token) externalviewreturns(bool){
return tokenUsed[token][oneOnetoken];
}
/**
* @dev set token base uri
*/functionsetURI(stringmemory baseURI) publiconlyOwner{
_setURI(baseURI);
}
/**
* @dev set token hash
*/functionsetTokenURI(uint256 token, stringmemory tokenURI) publiconlyMinter{
tokenUri[token]=tokenURI;
}
/**
* @dev removing the token substituion and replacing it with the implementation of the ERC721
*/functionuri(uint256 token) publicviewvirtualoverridereturns (stringmemory) {
stringmemory baseURI =super.uri(token);
returnbytes(baseURI).length>0 ? string(abi.encodePacked(baseURI, tokenUri[token])) : "";
}
///////////// Add name and symbol for etherscan /////////////////functionname() publicpurereturns (stringmemory) {
return _name;
}
functionsymbol() publicpurereturns (stringmemory) {
return _symbol;
}
///////////// Overwrites /////////////function_beforeTokenTransfer(address operator,
addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) internalvirtualoverride(ERC1155, ERC1155Supply) {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
}
Contract Source Code
File 3 of 17: Context.sol
Contract Source Code
File 4 of 17: ERC1155.sol
Contract Source Code
File 5 of 17: ERC1155Burnable.sol
Contract Source Code
File 6 of 17: ERC1155Pausable.sol
Contract Source Code
File 7 of 17: ERC1155Supply.sol
Contract Source Code
File 8 of 17: ERC165.sol
Contract Source Code
File 9 of 17: EnumerableSet.sol
Contract Source Code
File 10 of 17: IERC1155.sol
Contract Source Code
File 11 of 17: IERC1155MetadataURI.sol
Contract Source Code
File 12 of 17: IERC1155Receiver.sol
Contract Source Code
File 13 of 17: IERC165.sol
Contract Source Code
File 14 of 17: IERC721.sol
Contract Source Code
File 15 of 17: Mintable.sol
// SPDX-License-Identifier: MITpragmasolidity ^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.
*/abstractcontractMintableisOwnable{
usingEnumerableSetforEnumerableSet.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.
*/functiongetMinters() externalviewreturns (address[] memory minters) {
minters =newaddress[](_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.
*/modifieronlyMinter() {
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.
*/functionaddMinter(address newMinter) externalvirtualonlyOwner{
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
*/functionrevokeMinter(address minter) externalonlyOwner{
if (_minters.contains(minter)) {
_minters.remove(minter);
}
}
function_addMinter(address newMinter) private{
_minters.add(newMinter);
}
}