编译器
0.8.11+commit.d7f03943
文件 1 的 7:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 2 的 7:ERC721.sol
pragma solidity ^0.8.0;
import { ERC721TokenReceiver } from "./ERC721TokenReceiver.sol";
abstract contract ERC721 {
event Transfer(address indexed from, address indexed to, uint256 indexed id);
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
string private _name;
string private _symbol;
mapping(uint256 => address) internal _tokenApprovals;
mapping(address => mapping(address => bool)) internal _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 ||
interfaceId == 0x80ac58cd ||
interfaceId == 0x5b5e139f ||
interfaceId == 0x780e9d63;
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function tokenURI(uint256 id) public view virtual returns (string memory);
function totalSupply() public view virtual returns (uint256);
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
function tokenByIndex(uint256 index) public view virtual returns (uint256);
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
function balanceOf(address owner) public view virtual returns (uint256);
function ownerOf(uint256 id) public view virtual returns (address);
function _exists(uint256 id) internal view virtual returns (bool);
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
function _mint(address to, uint256 amount) internal virtual;
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
function toString(uint256 value) internal pure virtual returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
}
文件 3 的 7:ERC721M.sol
pragma solidity ^0.8.0;
import { ERC721 } from "./ERC721.sol";
abstract contract ERC721M is ERC721 {
address[] internal _owners;
constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) {
_owners.push();
}
function totalSupply() public view override returns (uint256) {
unchecked {
return _owners.length - 1;
}
}
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < balanceOf(owner), "INVALID_INDEX");
unchecked {
uint256 count;
uint256 _currentIndex = _owners.length;
for (uint256 i; i < _currentIndex; i++) {
if (owner == ownerOf(i)) {
if (count == index) return i;
else count++;
}
}
}
revert("NOT_FOUND");
}
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(_exists(index), "INVALID_INDEX");
return index;
}
function balanceOf(address owner) public view virtual override returns (uint256 balance) {
require(owner != address(0), "INVALID_OWNER");
unchecked {
uint256 _currentIndex = _owners.length;
for (uint256 i = 1; i < _currentIndex; i++) {
if (owner == ownerOf(i)) {
balance++;
}
}
}
}
function ownerOf(uint256 id) public view virtual override returns (address owner) {
require(_exists(id), "NONEXISTENT_TOKEN");
for (uint256 i = id; ; i++) {
owner = _owners[i];
if (owner != address(0)) {
return owner;
}
}
}
function _mint(address to, uint256 amount) internal virtual override {
require(to != address(0), "INVALID_RECIPIENT");
require(amount != 0, "INVALID_AMOUNT");
unchecked {
uint256 _currentIndex = _owners.length;
for (uint256 i; i < amount - 1; i++) {
_owners.push();
emit Transfer(address(0), to, _currentIndex + i);
}
_owners.push(to);
emit Transfer(address(0), to, _currentIndex + (amount - 1));
}
}
function _exists(uint256 id) internal view virtual override returns (bool) {
return id != 0 && id < _owners.length;
}
function _transfer(
address from,
address to,
uint256 id
) internal virtual override {
require(ownerOf(id) == from, "WRONG_FROM");
require(to != address(0), "INVALID_RECIPIENT");
require(msg.sender == from || getApproved(id) == msg.sender || isApprovedForAll(from, msg.sender), "NOT_AUTHORIZED");
delete _tokenApprovals[id];
_owners[id] = to;
unchecked {
uint256 prevId = id - 1;
if (_owners[prevId] == address(0)) {
_owners[prevId] = from;
}
}
emit Transfer(from, to, id);
}
}
文件 4 的 7:ERC721TokenReceiver.sol
pragma solidity ^0.8.0;
interface ERC721TokenReceiver {
function onERC721Received(
address operator,
address from,
uint256 id,
bytes calldata data
) external returns (bytes4);
}
文件 5 的 7:ERC721Tradable.sol
pragma solidity ^0.8.0;
import { ERC721 } from "../ERC721.sol";
interface IProxyRegistry {
function proxies(address) external view returns (address);
}
abstract contract ERC721Tradable is ERC721 {
address public immutable openSeaProxyRegistry;
address public immutable looksRareTransferManager;
bool public marketPlaceApprovalForAll = true;
constructor(address _openSeaProxyRegistry, address _looksRareTransferManager) {
require(_openSeaProxyRegistry != address(0) && _looksRareTransferManager != address(0), "INVALID_ADDRESS");
openSeaProxyRegistry = _openSeaProxyRegistry;
looksRareTransferManager = _looksRareTransferManager;
}
function setMarketplaceApprovalForAll(bool approved) public virtual;
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
if (marketPlaceApprovalForAll && (operator == IProxyRegistry(openSeaProxyRegistry).proxies(owner) || operator == looksRareTransferManager)) return true;
return super.isApprovedForAll(owner, operator);
}
}
文件 6 的 7:Mingoes.sol
pragma solidity ^0.8.0;
import { ERC721 } from "./ERC721/ERC721.sol";
import { ERC721M } from "./ERC721/ERC721M.sol";
import { ERC721Tradable } from "./ERC721/extensions/ERC721Tradable.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
contract Mingoes is ERC721M, ERC721Tradable, Ownable {
uint256 public constant PRICE = 0.04 ether;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_RESERVE = 300;
uint256 public constant MAX_PUBLIC = 9700;
uint256 public constant MAX_FREE = 200;
uint256 public constant MAX_TX = 20;
uint256 public reservesMinted;
string public baseURI;
bool public isSaleActive;
mapping (address => bool) public hasClaimed;
constructor(
address _openSeaProxyRegistry,
address _looksRareTransferManager,
string memory _baseURI
) payable ERC721M("Mingoes", "MINGOES") ERC721Tradable(_openSeaProxyRegistry, _looksRareTransferManager) {
baseURI = _baseURI;
}
function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
function _transferETH(address to, uint256 value) internal {
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
}
文件 7 的 7:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
{
"compilationTarget": {
"contracts/src/Mingoes.sol": "Mingoes"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 1000000
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_openSeaProxyRegistry","type":"address"},{"internalType":"address","name":"_looksRareTransferManager","type":"address"},{"internalType":"string","name":"_baseURI","type":"string"}],"stateMutability":"payable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","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":"id","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"MAX_FREE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_PUBLIC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_RESERVE","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":"MAX_TX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"hasClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"isSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"looksRareTransferManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketPlaceApprovalForAll","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":"openSeaProxyRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"owner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"publicMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"recipients","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"reserveMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reservesMinted","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":"id","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":"id","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":"string","name":"_baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isSaleActive","type":"bool"}],"name":"setIsSaleActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"approved","type":"bool"}],"name":"setMarketplaceApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","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":"id","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":"id","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"}]