// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
interface NftContract {
function mint(address) external;
}
contract BarnyardFashionistasStore is Ownable {
NftContract public bfNft =
NftContract(0xBAB7dF6D042F4b83b62070b670Da929b62eD22d8);
address private constant core1Address =
0x3002E0E7Db1FB99072516033b8dc2BE9897178bA;
uint256 private constant core1Shares = 84650;
address private constant core2Address =
0x452d40db156034223e8865F93d6a532aE62c4A99;
uint256 private constant core2Shares = 5000;
address private constant core3Address =
0xEbCEe6204eeEEf21e406C0A75734E70f342914e0;
uint256 private constant core3Shares = 5000;
address private constant core4Address =
0xcFE99FB901c76C7432E3CD823B38EF6ce055090b;
uint256 private constant core4Shares = 3000;
address private constant core5Address =
0xa808208Bb50e2395c63ce3fd41990d2E009E3053;
uint256 private constant core5Shares = 750;
address private constant core6Address =
0x1996FabEC51878e3Ff99cd07c6CaC9Ac668A22fD;
uint256 private constant core6Shares = 600;
address private constant core7Address =
0x30734A0adeCa7e07c3C960587d6502fC5EA0f8df;
uint256 private constant core7Shares = 500;
address private constant core8Address =
0x74E101B1E67Cd303A3ec896421ceCf894891ac25;
uint256 private constant core8Shares = 500;
uint256 private constant baseMod = 100000;
/**
Numbers for Barnyard Fashionistas NftContract
*/
// uint256 public constant maxFashionistas = 9999;
uint256 public maxFashionistas = 9999;
mapping(address => uint256) private whitelist;
/**
Team allocated Fashionistas
*/
// Fashionistas which is minted by the owner
uint256 public preMintedFashionistas = 0;
// MAX Fashionistas which owner can mint
uint256 public constant maxPreMintFashionistas = 300;
/**
Mint Pass
*/
uint256 public newlyMintedFashionistasPresale = 0;
mapping(address => uint256) public mintedFashionistasOf;
/**
Tracking Dweller Sales After Presale
*/
uint256 public mintedFashionistasAfterPresale = 0;
/**
Scheduling
*/
/**
Ticket
*/
uint256 public price = 0.071 ether;
// mapping(address => ticket) public ticketsOf;
// struct ticket {
// uint256 index; // Incl
// uint256 amount;
// }
/**
Security
*/
uint256 public constant maxMintPerTx = 30;
/**
Raffle
*/
uint256 public mintedFashionistas = 0;
event SetFashionistasNftContract(address bfNft);
event MintWithWhitelist(address account, uint256 amount, uint256 changes);
event SetRemainingFashionistas(uint256 remainingFashionistas);
event mintFashionistas(address account, uint256 amount);
event Withdraw(address to);
bool public presaleOn = false;
bool public mainSaleOn = false;
constructor() {
}
modifier mainSaleOpened() {
require( mainSaleOn, "Store is not opened" );
_;
}
modifier presaleOpened() {
require(presaleOn, "Store is not opened for Presale");
_;
}
modifier onlyOwnerOrTeam() {
require(
core1Address == msg.sender || core2Address == msg.sender || core4Address == msg.sender || owner() == msg.sender,
"caller is neither Team Wallet nor Owner"
);
_;
}
function setPrice(uint256 _newPrice) external onlyOwner {
price = _newPrice;
}
function togglePresale() external onlyOwner {
presaleOn = !presaleOn;
}
function toggleMainSale() external onlyOwner {
mainSaleOn = !mainSaleOn;
}
function presaleBalance() public view returns(uint256) {
return whitelist[msg.sender];
}
function setFashionistasNftContract(NftContract _bfNft) external onlyOwner {
bfNft = _bfNft;
emit SetFashionistasNftContract(address(_bfNft));
}
// Do not update newlyMintedFashionistas to prevent withdrawal
// This needs to become the owner Free mint function. Ditch the time restrictions?
function preMintFashionistas(address[] memory recipients) external onlyOwner {
uint256 totalRecipients = recipients.length;
require(
totalRecipients > 0,
"Number of recipients must be greater than 0"
);
require(
preMintedFashionistas + totalRecipients <= maxPreMintFashionistas,
"Exceeds max pre-mint Fashionistas"
);
require(
mintedFashionistas + totalRecipients < maxFashionistas,
"Exceeds max Fashionistas"
);
for (uint256 i = 0; i < totalRecipients; i++) {
address to = recipients[i];
require(to != address(0), "receiver can not be empty address");
bfNft.mint(to);
}
preMintedFashionistas += totalRecipients;
mintedFashionistas += totalRecipients;
}
// adds to whitelist with specified amounts
function addToWhitelistAmounts(address[] memory _listToAdd, uint256[] memory _amountPerAddress) public onlyOwner {
uint256 totalAddresses = _listToAdd.length;
uint256 totalAmounts = _amountPerAddress.length;
require(totalAddresses == totalAmounts, "Amounts of entered items do not match");
for (uint256 i = 0; i < totalAddresses; i++) {
whitelist[_listToAdd[i]] = _amountPerAddress[i];
}
}
function mintPresale( uint256 _count) public payable presaleOpened{
require(_count <= whitelist[msg.sender]);
require(mintedFashionistas + _count <= maxFashionistas, "Max limit");
require(msg.value >= (_count * price ), "Value below price");
for (uint256 i = 0; i < _count; i++) {
bfNft.mint(msg.sender);
}
newlyMintedFashionistasPresale += _count;
mintedFashionistas += _count;
whitelist[msg.sender] = whitelist[msg.sender] - _count;
}
// MAIN MINTING FUNCTION
function mintMainSale(uint256 _amount) external payable mainSaleOpened {
require(mintedFashionistas + _amount -1 < maxFashionistas, "exceeds max mint");
uint256 totalPrice = price * _amount;
require(totalPrice <= msg.value, "Not enough money");
require(_amount - 1 < maxMintPerTx, "exceed max transaction");
for (uint256 i = 0; i < _amount; i += 1) {
bfNft.mint(msg.sender);
}
mintedFashionistasAfterPresale += _amount;
mintedFashionistas += _amount;
emit mintFashionistas(msg.sender, _amount);
}
function withdrawCore() external onlyOwnerOrTeam {
uint256 balance = address(this).balance;
require(balance > 0);
_splitAll(balance);
}
// **** ASK HOW MANY CAN DO SAFE
function _splitAll(uint256 _amount) private {
uint256 singleShare = _amount / baseMod;
_withdraw(core1Address, singleShare * core1Shares);
_withdraw(core2Address, singleShare * core2Shares);
_withdraw(core3Address, singleShare * core3Shares);
_withdraw(core4Address, singleShare * core4Shares);
_withdraw(core5Address, singleShare * core5Shares);
_withdraw(core6Address, singleShare * core6Shares);
_withdraw(core7Address, singleShare * core7Shares);
_withdraw(core8Address, singleShare * core8Shares);
}
function withdrawBU() external onlyOwnerOrTeam {
uint256 balance = address(this).balance;
require(balance > 0);
_withdraw(core1Address, balance);
}
function _withdraw(address _address, uint256 _amount) private {
payable(_address).transfer(_amount);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
{
"compilationTarget": {
"contracts/BarnyardFashionistasStore.sol": "BarnyardFashionistasStore"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"changes","type":"uint256"}],"name":"MintWithWhitelist","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":false,"internalType":"address","name":"bfNft","type":"address"}],"name":"SetFashionistasNftContract","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"remainingFashionistas","type":"uint256"}],"name":"SetRemainingFashionistas","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mintFashionistas","type":"event"},{"inputs":[{"internalType":"address[]","name":"_listToAdd","type":"address[]"},{"internalType":"uint256[]","name":"_amountPerAddress","type":"uint256[]"}],"name":"addToWhitelistAmounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bfNft","outputs":[{"internalType":"contract NftContract","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mainSaleOn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxFashionistas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxMintPerTx","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPreMintFashionistas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mintMainSale","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"mintPresale","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintedFashionistas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintedFashionistasAfterPresale","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"mintedFashionistasOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"newlyMintedFashionistasPresale","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"recipients","type":"address[]"}],"name":"preMintFashionistas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"preMintedFashionistas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"presaleBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"presaleOn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract NftContract","name":"_bfNft","type":"address"}],"name":"setFashionistasNftContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newPrice","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleMainSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePresale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawBU","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawCore","outputs":[],"stateMutability":"nonpayable","type":"function"}]