文件 3 的 17:Dorkis.sol
pragma solidity ^0.8.0 <0.9.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.2.0/contracts/token/ERC721/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.2.0/contracts/access/Ownable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.2.0/contracts/utils/math/SafeMath.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.2.0/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "./Royalties.sol";
contract Dorkis is Ownable, ERC721Enumerable, Royalties {
using SafeMath for uint256;
string public DORKIS_PROVENANCE = "";
uint256 public dorksPrice = 70000000000000000;
uint public constant MAX_PURCHASE = 10;
uint public constant MAX_RESERVE = 30;
uint public constant MAX_SUPPLY_PER_ADDRESS = 100;
uint256 public MAX_DORKS;
bool public saleIsActive;
bool public paybackIsActive;
address payable[] private addr = new address payable[](1);
uint256[] private royalties = new uint256[](1);
string private _baseTokenURI = "ipfs://Qmb5xMEc738Ra25j4jTiAGNfqtQ17E9kUWGpJWN3utAdGm/";
event PaymentReleased(address to, uint256 amount);
address private constant TORI = 0x51Be0a47282afbE3a330F7738A0Ab5b277810Fe4;
address private constant FRANK = 0xF40Fd88ac59A206D009A07F8c09828a01e2ACC0d;
address private constant FCCVIEW = 0xf450a5d6C4205ca8151fb1c6FAF49A02c8A527FC;
address private constant DEAD = 0x000000000000000000000000000000000000dEaD;
constructor() ERC721("Dorkis", "DRK") {
MAX_DORKS = 10000;
addr[0]=payable(owner());
royalties[0]=650;
_safeMint( TORI, 0);
_safeMint( FRANK, 1);
_safeMint( FCCVIEW, 2);
}
function supportsInterface(bytes4 interfaceId) public view override (ERC721Enumerable,Royalties) returns (bool){
return ERC721.supportsInterface(interfaceId) || Royalties.supportsInterface(interfaceId) || super.supportsInterface(interfaceId);
}
function withdraw() public onlyOwner {
uint256 artists = address(this).balance / 5;
require(payable(TORI).send(artists));
require(payable(FRANK).send(artists));
require(payable(FCCVIEW).send(artists));
require(payable(owner()).send(artists*2));
emit PaymentReleased(owner(), artists*2);
}
function reserveDorkis() public onlyOwner {
require(totalSupply().add(MAX_RESERVE) <= MAX_DORKS, "Reserve would exceed max supply of Dorkis");
uint supply = totalSupply();
for (uint i = 0; i < MAX_RESERVE; i++) {
_safeMint(msg.sender, supply + i);
}
}
function setProvenanceHash(string memory provenanceHash) public onlyOwner {
DORKIS_PROVENANCE = provenanceHash;
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseTokenURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
function flipSaleState() public onlyOwner {
saleIsActive = !saleIsActive;
}
function flipBurnPaybakState() public onlyOwner {
paybackIsActive = !paybackIsActive;
}
function mintDorkis(uint numberOfTokens) public payable {
require(numberOfTokens > 0, "numberOfNfts cannot be 0");
require(saleIsActive, "Sale must be active to mint Dorkis");
require(numberOfTokens <= MAX_PURCHASE, "Can only mint 10 tokens at a time");
require(totalSupply().add(numberOfTokens) <= MAX_DORKS, "Purchase would exceed max supply of Dorkis");
require(dorksPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
require(balanceOf(msg.sender) + numberOfTokens <= MAX_SUPPLY_PER_ADDRESS, "Exceeds max minted tokens for this address (100)");
for(uint i = 0; i < numberOfTokens; i++) {
uint mintIndex = totalSupply();
if (totalSupply() < MAX_DORKS) {
_safeMint(msg.sender, mintIndex);
}
}
}
function preSale(address _to, uint256 numberOfTokens) external onlyOwner() {
require(totalSupply().add(numberOfTokens) <= MAX_DORKS, "Reserve would exceed max supply of Dorkis");
require(numberOfTokens <= MAX_PURCHASE, "Can only mint 10 tokens at a time");
uint256 supply = totalSupply();
for(uint256 i; i < numberOfTokens; i++){
_safeMint( _to, supply + i );
}
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
if (paybackIsActive && to == DEAD){
Address.sendValue(payable(from), (dorksPrice/100)*80);
emit PaymentReleased(from, (dorksPrice/100)*80);
}
}
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = super.ownerOf(tokenId);
require(owner != DEAD, "ERC721: owner query for nonexistent token");
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(super.ownerOf(tokenId) != DEAD, "ERC721Metadata: URI query for nonexistent token");
return super.tokenURI(tokenId);
}
function multiBurn(uint256[] memory tokenId) public {
for (uint i = 0; i < tokenId.length; i++) {
if (_isApprovedOrOwner(_msgSender(), tokenId[i])){
transferFrom(_msgSender(),DEAD,tokenId[i]);
}
}
}
function getTokensForAddress(address fromAddress) external view returns (uint256 [] memory){
uint256 tokenCount = balanceOf(fromAddress);
uint256 [] memory result = new uint256[](tokenCount);
uint256 total = totalSupply();
uint256 resultIndex = 0;
for (uint id = 0; id < total; id++) {
if (super.ownerOf(id)==fromAddress){
result[resultIndex] = id;
resultIndex++;
}
}
return result;
}
fallback() external payable { }
receive() external payable { }
function getFeeRecipients(uint256 tokenId) external view override returns (address payable[] memory){
require(_exists(tokenId), "DORKIS: FeeRecipients query for nonexistent token");
return addr;
}
function getFeeBps(uint256 tokenId) external view override returns (uint[] memory){
require(_exists(tokenId), "DORKIS: FeesBPS query for nonexistent token");
return royalties;
}
function getFees(uint256 tokenId) external view override returns (address payable[] memory, uint256[] memory){
require(_exists(tokenId), "DORKIS: Fees query for nonexistent token");
return (addr, royalties);
}
function royaltyInfo(uint256 tokenId, uint256 salePrice) external view override returns (address, uint256){
require(_exists(tokenId), "DORKIS: royaltyInfo query for nonexistent token");
return (address(this),(salePrice*royalties[0]/10000));
}
}
文件 6 的 17:ERC721Enumerable.sol
文件 7 的 17:HalloweenDorkis.sol
pragma solidity ^0.8.0 <0.9.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.2.0/contracts/token/ERC721/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.2.0/contracts/access/Ownable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.2.0/contracts/utils/math/SafeMath.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.2.0/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "./Dorkis.sol";
import "./Royalties.sol";
contract HalloweenDorkis is Ownable, ERC721Enumerable , Royalties {
using SafeMath for uint256;
uint256 public MAX_TOKENS;
uint256[] private royalties = new uint256[](1);
uint public constant MAX_PURCHASE = 25;
bool public freeMintIsActive;
bool[] private hasMinted;
Dorkis private dorkis;
address payable[] private addr = new address payable[](1);
address private dorkisContract = 0x0588a0182eE72F74D0BA3b1fC6f5109599A46A9C;
address private constant TORI = 0x51Be0a47282afbE3a330F7738A0Ab5b277810Fe4;
address private constant FRANK = 0xF40Fd88ac59A206D009A07F8c09828a01e2ACC0d;
address private constant FCCVIEW = 0xf450a5d6C4205ca8151fb1c6FAF49A02c8A527FC;
string private _baseTokenURI;
event priceChange(address _by, uint256 price);
event PaymentReleased(address to, uint256 amount);
constructor() ERC721("Halloween Dorkis", "HDRK") {
MAX_TOKENS = 4724;
hasMinted = new bool[](MAX_TOKENS);
_baseTokenURI = "ipfs://QmcYM19E4jkj996BPBJtYvSf9DDj4UrQpcJQNaxoeLELTU/";
dorkis = Dorkis(payable(dorkisContract));
addr[0]=payable(owner());
royalties[0]=650;
_safeMint(TORI, 0);
_safeMint(FRANK, 1);
_safeMint(FCCVIEW, 2);
hasMinted[0]=true;
hasMinted[1]=true;
hasMinted[2]=true;
}
function supportsInterface(bytes4 interfaceId) public view override (ERC721Enumerable,Royalties) returns (bool){
return ERC721.supportsInterface(interfaceId) || Royalties.supportsInterface(interfaceId) || super.supportsInterface(interfaceId);
}
function getTokensForAddress(address fromAddress) external view returns (uint256 [] memory){
uint tokenCount = balanceOf(fromAddress);
uint256[] memory tokensId = new uint256[](tokenCount);
for(uint i = 0; i < tokenCount; i++){
tokensId[i] = tokenOfOwnerByIndex(fromAddress, i);
}
return tokensId;
}
function getDorkisForAddress(address fromAddress) external view returns (uint256 [] memory){
return dorkis.getTokensForAddress(fromAddress);
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseTokenURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
function flipFreeMintState() public onlyOwner {
freeMintIsActive = !freeMintIsActive;
}
function setDorkisContract(address newAddress) public onlyOwner {
dorkis = Dorkis(payable(newAddress));
}
function numberOfMintsForArray(uint256 [] memory dorkisMinted) external view returns (uint){
uint counter = 0;
for (uint id = 0; id < dorkisMinted.length; id++) {
if(!hasMinted[dorkisMinted[id]]){
counter += 1;
}
}
return counter;
}
function mintFreeHalloweenDorkis(uint256 [] memory tokenIds) external {
require(freeMintIsActive, "Free Mint Sale must be active to mint the Free Dorkis");
preMintChecks(tokenIds.length);
for(uint i = 0; i < tokenIds.length; i++) {
require(dorkis.ownerOf(tokenIds[i]) == msg.sender);
_safeMint(msg.sender, tokenIds[i]);
hasMinted[tokenIds[i]]=true;
}
}
function preMintChecks(uint numberOfTokens) internal view {
require(numberOfTokens > 0, "numberOfNfts cannot be 0.");
require(numberOfTokens <= MAX_PURCHASE, "Can only mint 25 tokens at a time.");
require(totalSupply().add(numberOfTokens) <= MAX_TOKENS, "Purchase would exceed max supply of Dorkis");
}
function getMintedDorkis() public view returns (bool [] memory){
return hasMinted;
}
function getFeeRecipients(uint256 tokenId) external view override returns (address payable[] memory){
require(_exists(tokenId), "EVIL DORKIS: FeeRecipients query for nonexistent token");
return addr;
}
function getFeeBps(uint256 tokenId) external view override returns (uint[] memory){
require(_exists(tokenId), "EVIL DORKIS: FeesBPS query for nonexistent token");
return royalties;
}
function getFees(uint256 tokenId) external view override returns (address payable[] memory, uint256[] memory){
require(_exists(tokenId), "EVIL DORKIS: Fees query for nonexistent token");
return (addr, royalties);
}
function royaltyInfo(uint256 tokenId, uint256 salePrice) external view override returns (address, uint256){
require(_exists(tokenId), "EVIL DORKIS: royaltyInfo query for nonexistent token");
return (address(this),(salePrice*royalties[0]/10000));
}
}
文件 10 的 17:IERC721Enumerable.sol
文件 11 的 17:IERC721Metadata.sol
文件 12 的 17:IERC721Receiver.sol
文件 13 的 17:IRoyalties.sol
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.2.0/contracts/utils/introspection/IERC165.sol";
interface IRoyalties is IERC165 {
function getFeeRecipients(uint256 tokenId) external view returns (address payable[] memory);
function getFeeBps(uint256 tokenId) external view returns (uint[] memory);
function getFees(uint256 tokenId) external view returns (address payable[] memory, uint256[] memory);
function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address, uint256);
}
文件 15 的 17:Royalties.sol
pragma solidity ^0.8.0;
import "./IRoyalties.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.2.0/contracts/utils/introspection/ERC165.sol";
abstract contract Royalties is IRoyalties, ERC165 {
bytes4 private constant _INTERFACE_ID_ROYALTIES_RARIBLE = 0xb7799584;
bytes4 private constant _INTERFACE_ID_ROYALTIES_FOUNDATION = 0xd5a06d4c;
bytes4 private constant _INTERFACE_ID_ROYALTIES_EIP2981 = 0x2a55205a;
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IRoyalties).interfaceId || super.supportsInterface(interfaceId)
|| interfaceId == _INTERFACE_ID_ROYALTIES_RARIBLE
|| interfaceId == _INTERFACE_ID_ROYALTIES_FOUNDATION
|| interfaceId == _INTERFACE_ID_ROYALTIES_EIP2981;
}
}
{
"compilationTarget": {
"contracts/HalloweenDorkis.sol": "HalloweenDorkis"
},
"evmVersion": "berlin",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"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":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PaymentReleased","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_by","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"priceChange","type":"event"},{"inputs":[],"name":"MAX_PURCHASE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_TOKENS","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":"flipFreeMintState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"freeMintIsActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fromAddress","type":"address"}],"name":"getDorkisForAddress","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getFeeBps","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getFeeRecipients","outputs":[{"internalType":"address payable[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getFees","outputs":[{"internalType":"address payable[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMintedDorkis","outputs":[{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fromAddress","type":"address"}],"name":"getTokensForAddress","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":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"mintFreeHalloweenDorkis","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"dorkisMinted","type":"uint256[]"}],"name":"numberOfMintsForArray","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":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"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":"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":"string","name":"baseURI","type":"string"}],"name":"setBaseTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"setDorkisContract","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"}]