编译器
0.8.10+commit.fc410830
文件 1 的 6: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 的 6:ERC721.sol
pragma solidity >=0.8.0;
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 public name;
string public symbol;
function tokenURI(uint256 id) public view virtual returns (string memory);
mapping(uint256 => address) internal _ownerOf;
mapping(address => uint256) internal _balanceOf;
function ownerOf(uint256 id) public view virtual returns (address owner) {
require((owner = _ownerOf[id]) != address(0), "NOT_MINTED");
}
function balanceOf(address owner) public view virtual returns (uint256) {
require(owner != address(0), "ZERO_ADDRESS");
return _balanceOf[owner];
}
mapping(uint256 => address) public getApproved;
mapping(address => mapping(address => bool)) public isApprovedForAll;
constructor(string memory _name, string memory _symbol) {
name = _name;
symbol = _symbol;
}
function approve(address spender, uint256 id) public virtual {
address owner = _ownerOf[id];
require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED");
getApproved[id] = spender;
emit Approval(owner, spender, id);
}
function setApprovalForAll(address operator, bool approved) public virtual {
isApprovedForAll[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
require(from == _ownerOf[id], "WRONG_FROM");
require(to != address(0), "INVALID_RECIPIENT");
require(
msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id],
"NOT_AUTHORIZED"
);
unchecked {
_balanceOf[from]--;
_balanceOf[to]++;
}
_ownerOf[id] = to;
delete getApproved[id];
emit Transfer(from, to, id);
}
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
transferFrom(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 calldata data
) public virtual {
transferFrom(from, to, id);
require(
to.code.length == 0 ||
ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) ==
ERC721TokenReceiver.onERC721Received.selector,
"UNSAFE_RECIPIENT"
);
}
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 ||
interfaceId == 0x80ac58cd ||
interfaceId == 0x5b5e139f;
}
function _mint(address to, uint256 id) internal virtual {
require(to != address(0), "INVALID_RECIPIENT");
require(_ownerOf[id] == address(0), "ALREADY_MINTED");
unchecked {
_balanceOf[to]++;
}
_ownerOf[id] = to;
emit Transfer(address(0), to, id);
}
function _burn(uint256 id) internal virtual {
address owner = _ownerOf[id];
require(owner != address(0), "NOT_MINTED");
unchecked {
_balanceOf[owner]--;
}
delete _ownerOf[id];
delete getApproved[id];
emit Transfer(owner, address(0), id);
}
function _safeMint(address to, uint256 id) internal virtual {
_mint(to, id);
require(
to.code.length == 0 ||
ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, "") ==
ERC721TokenReceiver.onERC721Received.selector,
"UNSAFE_RECIPIENT"
);
}
function _safeMint(
address to,
uint256 id,
bytes memory data
) internal virtual {
_mint(to, id);
require(
to.code.length == 0 ||
ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) ==
ERC721TokenReceiver.onERC721Received.selector,
"UNSAFE_RECIPIENT"
);
}
}
abstract contract ERC721TokenReceiver {
function onERC721Received(
address,
address,
uint256,
bytes calldata
) external virtual returns (bytes4) {
return ERC721TokenReceiver.onERC721Received.selector;
}
}
文件 3 的 6:FoodzPartyV2.sol
pragma solidity >=0.8.4;
import {ERC721} from "@solmate/tokens/ERC721.sol";
import {Ownable} from "@openzeppelin/access/Ownable.sol";
import {MerkleProof} from "@openzeppelin/utils/cryptography/MerkleProof.sol";
import {Strings} from "@openzeppelin/utils/Strings.sol";
interface IGoldenPass {
function burn(address from, uint256 amount) external;
}
interface IFoodzPartyLegacy {
function transferFrom(
address from,
address to,
uint256 id
) external;
}
interface IOddworxStaking {
function buyItem(
uint256 itemSKU,
uint256 amount,
address nftContract,
uint256[] calldata nftIds,
address user
) external;
}
contract FoodzPartyV2 is ERC721, Ownable {
using Strings for uint256;
error MaxSupply();
error MigrationOff();
error PassSaleOff();
error SaleOff();
error QueryForNonExistentToken();
error InvalidAddress();
error InvalidAmount();
error Reentrancy();
uint256 internal constant MIGRATION_START_INDEX = 0;
uint256 internal constant MIGRATION_END_INDEX = 1160;
uint256 internal constant MIGRATION_EXTRAS_START_INDEX = 1161;
uint256 internal constant MIGRATION_EXTRAS_END_INDEX = 2321;
uint256 internal constant REGULAR_START_INDEX = 2322;
uint256 internal constant REGULAR_END_INDEX = 2975;
uint256 internal constant GOLDEN_PASS_START_INDEX = 2976;
uint256 internal constant GOLDEN_PASS_END_INDEX = 3475;
uint256 internal constant HANDMADE_START_INDEX = 3476;
uint256 internal constant HANDMADE_END_INDEX = 3499;
IOddworxStaking internal immutable staking;
IGoldenPass internal immutable goldenPass;
IFoodzPartyLegacy internal immutable foodzLegacy;
address internal immutable genzee;
uint256 public migrationSupply = 1;
uint256 public migrationExtrasSupply;
uint256 public regularSupply;
uint256 public goldenPassSupply;
uint256 public handmadeSupply;
string public baseURI;
uint256 public mintPriceOddx = 200 ether;
uint256 private _isMigrationActive = 1;
uint256 private _isPassSaleActive = 1;
uint256 private _isSaleActive = 1;
uint256 private _locked = 1;
constructor(
IOddworxStaking staking_,
IGoldenPass goldenPass_,
IFoodzPartyLegacy foodzLegacy_,
address genzee_,
string memory baseURI_
) ERC721("Foodz Party", "FP") {
staking = staking_;
goldenPass = goldenPass_;
foodzLegacy = foodzLegacy_;
genzee = genzee_;
baseURI = baseURI_;
_safeMint(0x067423C244442ca0Eb6d6fd6B747c2BD21414107, 0);
}
function setBaseURI(string calldata newBaseURI) external onlyOwner {
baseURI = newBaseURI;
}
function setIsPassSaleActive(bool newIsPassSaleActive) external onlyOwner {
_isPassSaleActive = newIsPassSaleActive ? 2 : 1;
}
function setIsSaleActive(bool newIsSaleActive) external onlyOwner {
_isSaleActive = newIsSaleActive ? 2 : 1;
}
function setIsMigrationActive(bool newIsMigrationActive)
external
onlyOwner
{
_isMigrationActive = newIsMigrationActive ? 2 : 1;
}
function setMintPriceOddx(uint256 newMintPriceOddx) external onlyOwner {
mintPriceOddx = newMintPriceOddx;
}
function handmadeMint(address to) external onlyOwner {
unchecked {
uint256 tokenId = HANDMADE_START_INDEX + handmadeSupply;
if (tokenId > HANDMADE_END_INDEX) revert MaxSupply();
++handmadeSupply;
_safeMint(to, tokenId);
}
}
function migrate(uint256[] calldata ids) external {
if (_isMigrationActive != 2) revert MigrationOff();
if (msg.sender == address(0)) revert InvalidAddress();
if (_locked == 2) revert Reentrancy();
_locked = 2;
uint256 length = ids.length;
uint256 i = 0;
unchecked {
migrationSupply += length;
}
for (i = 0; i < length; ) {
foodzLegacy.transferFrom(
msg.sender,
address(0x000000000000000000000000000000000000dEaD),
ids[i]
);
unchecked {
++i;
}
}
unchecked {
uint256 extraMingStartIndex = MIGRATION_EXTRAS_START_INDEX +
migrationExtrasSupply;
migrationExtrasSupply += length;
for (i = 0; i < length; i++) {
_safeMint(msg.sender, ids[i]);
_safeMint(msg.sender, extraMingStartIndex + i);
}
}
_locked = 1;
}
function mint(uint256 amount, uint256[] calldata nftIds) external {
if (amount == 0) revert InvalidAmount();
if (_isSaleActive != 2) revert SaleOff();
uint256 startIndex;
unchecked {
startIndex = REGULAR_START_INDEX + regularSupply;
if (startIndex + amount - 1 > REGULAR_END_INDEX) revert MaxSupply();
}
staking.buyItem(
0x0105,
amount * mintPriceOddx,
genzee,
nftIds,
msg.sender
);
unchecked {
regularSupply += amount;
for (uint256 i = 0; i < amount; i++) {
_safeMint(msg.sender, startIndex + i);
}
}
}
function passmint(uint256 amount) external {
if (_isPassSaleActive != 2) revert PassSaleOff();
uint256 startIndex;
unchecked {
startIndex = GOLDEN_PASS_START_INDEX + goldenPassSupply;
if (startIndex + amount - 1 > GOLDEN_PASS_END_INDEX)
revert MaxSupply();
}
goldenPass.burn(msg.sender, amount);
unchecked {
goldenPassSupply += amount;
for (uint256 i = 0; i < amount; i++) {
_safeMint(msg.sender, startIndex + i);
}
}
}
function currentSupply() external view returns (uint256) {
unchecked {
return
migrationSupply +
migrationExtrasSupply +
regularSupply +
goldenPassSupply +
handmadeSupply;
}
}
function isMigrationActive() external view returns (bool) {
return _isMigrationActive == 2 ? true : false;
}
function isPassSaleActive() external view returns (bool) {
return _isPassSaleActive == 2 ? true : false;
}
function isSaleActive() external view returns (bool) {
return _isSaleActive == 2 ? true : false;
}
function tokenURI(uint256 id) public view override returns (string memory) {
if (_ownerOf[id] == address(0)) revert QueryForNonExistentToken();
return string(abi.encodePacked(baseURI, id.toString()));
}
}
文件 4 的 6:MerkleProof.sol
pragma solidity ^0.8.0;
library MerkleProof {
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
computedHash = _efficientHash(computedHash, proofElement);
} else {
computedHash = _efficientHash(proofElement, computedHash);
}
}
return computedHash;
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
文件 5 的 6: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);
}
}
文件 6 的 6:Strings.sol
pragma solidity ^0.8.0;
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
function toString(uint256 value) internal pure 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);
}
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
{
"compilationTarget": {
"src/FoodzPartyV2.sol": "FoodzPartyV2"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":$/=src/",
":@ds-test/=lib/ds-test/src/",
":@forge-std/=lib/forge-std/src/",
":@oddworx/=lib/contracts-flatten/contracts/",
":@openzeppelin/=lib/openzeppelin-contracts/contracts/",
":@solmate/=lib/solmate/src/",
":contracts-flatten/=lib/contracts-flatten/contracts/",
":ds-test/=lib/ds-test/src/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":solmate/=lib/solmate/src/",
":src/=src/"
]
}
[{"inputs":[{"internalType":"contract IOddworxStaking","name":"staking_","type":"address"},{"internalType":"contract IGoldenPass","name":"goldenPass_","type":"address"},{"internalType":"contract IFoodzPartyLegacy","name":"foodzLegacy_","type":"address"},{"internalType":"address","name":"genzee_","type":"address"},{"internalType":"string","name":"baseURI_","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"MaxSupply","type":"error"},{"inputs":[],"name":"MigrationOff","type":"error"},{"inputs":[],"name":"PassSaleOff","type":"error"},{"inputs":[],"name":"QueryForNonExistentToken","type":"error"},{"inputs":[],"name":"Reentrancy","type":"error"},{"inputs":[],"name":"SaleOff","type":"error"},{"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":[{"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":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"goldenPassSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"handmadeMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"handmadeSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isMigrationActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPassSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"migrationExtrasSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"migrationSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256[]","name":"nftIds","type":"uint256[]"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintPriceOddx","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"id","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"owner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"passmint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"regularSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"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":"newBaseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"newIsMigrationActive","type":"bool"}],"name":"setIsMigrationActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"newIsPassSaleActive","type":"bool"}],"name":"setIsPassSaleActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"newIsSaleActive","type":"bool"}],"name":"setIsSaleActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMintPriceOddx","type":"uint256"}],"name":"setMintPriceOddx","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":"id","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"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"}]