pragma solidity ^0.7.3;
import "./MyNFT.sol";
contract BearMarketBears is MyNFT {
using SafeMath for uint256;
// dom, 0x...90F7
address payable address1 = 0xE4A9Dc8F01B3c294e3De1ce2893E950EADC990F7;
// justin, 0x...2AE5
address payable address2 = 0x9DF6E4E37fDD684583841D60da68571fD07D2A85;
// hamm, 0x...D26C
address payable address3 = 0x5be495FFE3C171babdDd16AFb8BA816deF29d26c;
// charity, 0x...45D5
address payable address4 = 0x448067B0bCcc28c1d2653F54eEd9eEE9D7Ba45D5;
constructor() MyNFT(
"BearMarketBears",
"BEAR",
35000000000000000 wei,
10000,
100,
9999,
"ipfs://QmfWD7yKM4d8LC34KE87QifAwnj25b7xepEBoZTrUHcYE2/") {
}
function withdraw() public onlyOwner {
uint balance = address(this).balance;
address1.transfer(balance * 33 / 100);
address2.transfer(balance * 33 / 100);
address3.transfer(balance * 33 / 100);
address4.transfer(balance * 1 / 100);
}
}
pragma solidity ^0.7.3;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4/contracts/token/ERC721/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4/contracts/access/Ownable.sol";
contract MyNFT is ERC721, Ownable {
using SafeMath for uint256;
uint256 public _price = 0;
uint256 public _max_supply = 0;
string public _baseURI = "";
uint256 public _initial_purchase_index = 0;
uint256 public _final_purchase_index = 0;
uint256 public _current_purchase_index = 0;
address public _owner;
constructor(string memory name, string memory symbol, uint256 price, uint256 max_supply, uint256 initial_purchase_index, uint256 final_purchase_index, string memory base_uri) ERC721(name, symbol) {
_owner = msg.sender;
_price = price;
_max_supply = max_supply;
_initial_purchase_index = initial_purchase_index;
_final_purchase_index = final_purchase_index;
_current_purchase_index = initial_purchase_index;
updateBaseTokenURI(string(abi.encodePacked(base_uri)));
}
function update(uint256 price, uint256 max_supply, uint256 initial_purchase_index, uint256 current_purchase_index, uint256 final_purchase_index, string memory base_uri) public onlyOwner {
_price = price;
_max_supply = max_supply;
_initial_purchase_index = initial_purchase_index;
_final_purchase_index = final_purchase_index;
_current_purchase_index = current_purchase_index;
updateBaseTokenURI(string(abi.encodePacked(base_uri)));
}
function updateBaseTokenURI(string memory baseURI) public onlyOwner {
_setBaseURI(baseURI);
_baseURI = baseURI;
}
function ownerMint(uint tokenId) public onlyOwner {
_secureMint(msg.sender, tokenId);
}
function ownerMint(uint[] memory tokenIds) public onlyOwner {
for (uint i = 0; i < tokenIds.length; i++){
uint tokenId = tokenIds[i];
_secureMint(msg.sender, tokenId);
}
}
function ownerMint(uint tokenId, address to) public onlyOwner {
_secureMint(to, tokenId);
}
function ownerMint(uint[] memory tokenIds, address to) public onlyOwner {
for (uint i = 0; i < tokenIds.length; i++){
uint tokenId = tokenIds[i];
_secureMint(to, tokenId);
}
}
function purchaseNextTokens(uint numberOfTokens) public payable {
require(_price.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
require(totalSupply().add(numberOfTokens) <= _max_supply, "Minting would exceed max supply");
uint tokensMinted = 0;
for(uint i = _current_purchase_index; i < _max_supply; i++) {
if (tokensMinted == numberOfTokens){
break;
}
else if (!_exists(i)){
require(i <= _final_purchase_index, "Minting would exceed final purchase index");
_secureMint(msg.sender, i);
tokensMinted += 1;
_current_purchase_index = i;
}
}
require(tokensMinted == numberOfTokens, "Not enough tokens to mint");
}
function _secureMint(address to, uint256 tokenId) internal virtual {
require(tokenId <= _max_supply, "Token index out of bounds");
require(tokenId > 0, "Token index out of bounds");
_mint(to, tokenId);
}
function getBaseURI() public view returns (string memory) {
return _baseURI;
}
function getPrice() public view virtual returns (uint256) {
return _price;
}
function getMaxSupply() public view virtual returns (uint256) {
return _max_supply;
}
}
{
"compilationTarget": {
"contracts/BMB.sol": "BearMarketBears"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","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":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"_baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_current_purchase_index","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_final_purchase_index","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_initial_purchase_index","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_max_supply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBaseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"ownerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"address","name":"to","type":"address"}],"name":"ownerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"ownerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"numberOfTokens","type":"uint256"}],"name":"purchaseNextTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","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":"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":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"max_supply","type":"uint256"},{"internalType":"uint256","name":"initial_purchase_index","type":"uint256"},{"internalType":"uint256","name":"current_purchase_index","type":"uint256"},{"internalType":"uint256","name":"final_purchase_index","type":"uint256"},{"internalType":"string","name":"base_uri","type":"string"}],"name":"update","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI","type":"string"}],"name":"updateBaseTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]