编译器
0.8.11+commit.d7f03943
文件 1 的 12: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 的 12:IColonist.sol
pragma solidity ^0.8.0;
interface IColonist {
struct Colonist {
bool isColonist;
uint8 background;
uint8 body;
uint8 shirt;
uint8 jacket;
uint8 jaw;
uint8 eyes;
uint8 hair;
uint8 held;
uint8 gen;
}
struct HColonist {
uint8 Legendary;
}
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) external;
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function isOwner(uint256 tokenId)
external
view
returns (address);
function minted() external returns (uint16);
function totalCir() external returns (uint256);
function _mintColonist(address recipient, uint256 seed) external;
function _mintToHonors(address recipient, uint256 seed) external;
function _mintHonors(address recipient, uint8 id) external;
function burn(uint256 tokenId) external;
function getMaxTokens() external view returns (uint256);
function getPaidTokens() external view returns (uint256);
function getTokenTraitsColonist(uint256 tokenId)
external
view
returns (Colonist memory);
function getTokenTraitsHonors(uint256 tokenId)
external
view
returns (HColonist memory);
function tokenNameByIndex(uint256 index)
external
view
returns (string memory);
function hasBeenNamed(uint256 tokenId) external view returns (bool);
function nameColonist(uint256 tokenId, string memory newName) external;
}
文件 3 的 12:IEON.sol
pragma solidity ^0.8.0;
interface IEON {
function mint(address to, uint256 amount) external;
function burn(address from, uint256 amount) external;
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
}
文件 4 的 12:IImperialGuild.sol
pragma solidity ^0.8.0;
interface IImperialGuild {
function getBalance(
address account,
uint256 id
) external returns(uint256);
function mint(
uint256 typeId,
uint256 paymentId,
uint16 qty,
address recipient
) external;
function burn(
uint256 typeId,
uint16 qty,
address burnFrom
) external;
function handlePayment(uint256 amount) external;
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) external;
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) external;
}
文件 5 的 12:IOrbitalBlockade.sol
pragma solidity ^0.8.0;
interface IOrbitalBlockade {
function addPiratesToCrew(address account, uint16[] calldata tokenIds)
external;
function claimPiratesFromCrew(address account, uint16[] calldata tokenIds, bool unstake)
external;
function payPirateTax(uint256 amount) external;
function randomPirateOwner(uint256 seed) external view returns (address);
}
文件 6 的 12:IPytheas.sol
pragma solidity ^0.8.0;
interface IPytheas {
function addColonistToPytheas(address account, uint16[] calldata tokenIds)
external;
function claimColonistFromPytheas(address account, uint16[] calldata tokenIds, bool unstake)
external;
function getColonistMined(address account, uint16 tokenId)
external
returns (uint256);
function handleJoinPirates(address addr, uint16 tokenId) external;
function payUp(
uint16 tokenId,
uint256 amtMined,
address addr
) external;
}
文件 7 的 12:IRAW.sol
pragma solidity ^0.8.0;
interface IRAW {
function getBalance(
address account,
uint256 id
) external returns(uint256);
function mint(
uint256 typeId,
uint256 qty,
address recipient
) external;
function burn(
uint256 typeId,
uint256 qty,
address burnFrom
) external;
function updateMintBurns(
uint256 typeId,
uint256 mintQty,
uint256 burnQty
) external;
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) external;
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) external;
}
文件 8 的 12:IShatteredWL.sol
pragma solidity ^0.8.0;
interface IShatteredWL {}
文件 9 的 12:ITColonist.sol
pragma solidity ^0.8.0;
interface ITColonist {
function tokenURI(uint256 tokenId) external view returns (string memory);
}
文件 10 的 12:MerkleProof.sol
pragma solidity ^0.8.0;
library MerkleProof {
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash == root;
}
}
文件 11 的 12:Pausable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Pausable is Context {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor() {
_paused = false;
}
function paused() public view virtual returns (bool) {
return _paused;
}
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
文件 12 的 12:ShatteredWL.sol
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "./interfaces/IShatteredWL.sol";
import "./interfaces/IPytheas.sol";
import "./interfaces/IOrbitalBlockade.sol";
import "./interfaces/IColonist.sol";
import "./interfaces/ITColonist.sol";
import "./interfaces/IEON.sol";
import "./interfaces/IRAW.sol";
import "./interfaces/IImperialGuild.sol";
contract ShatteredWL is IShatteredWL, Pausable {
mapping(address => bool) private admins;
struct HonorsList {
bool isHonorsMember;
bool hasClaimed;
uint8 honorsId;
}
address public auth;
address payable ImperialGuildTreasury;
bool public hasPublicSaleStarted;
bool public isWLactive;
bool public isHonorsActive;
uint256 public constant paidTokens = 10000;
uint256 public constant whitelistPrice = 0.08 ether;
uint256 public constant publicPrice = 0.08 ether;
mapping(address => uint8) private _WLmints;
mapping(address => HonorsList) private _honorsAddresses;
event newUser(address newUser);
bytes32 internal merkleRoot =
0xd60676eb70cb99e173a40e78e3c1d139722ab50092a4afb575ee44c5c3e78e7f;
bytes32 internal entropySauce;
IColonist public colonistNFT;
constructor() {
_pause();
auth = msg.sender;
admins[msg.sender] = true;
}
modifier requireContractsSet() {
require(
address(colonistNFT) != address(0),
"Contracts not set"
);
_;
}
modifier noCheaters() {
uint256 size = 0;
address acc = msg.sender;
assembly {
size := extcodesize(acc)
}
require(
admins[msg.sender] || (msg.sender == tx.origin && size == 0),
"you're trying to cheat!"
);
_;
entropySauce = keccak256(abi.encodePacked(acc, block.coinbase));
}
modifier onlyOwner() {
require(msg.sender == auth);
_;
}
function setContracts(address _colonistNFT) external onlyOwner {
colonistNFT = IColonist(_colonistNFT);
}
function WlMintColonist(uint256 amount, bytes32[] calldata _merkleProof)
external
payable
noCheaters
whenNotPaused
{
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
uint16 minted = colonistNFT.minted();
require(isWLactive == true, "whitelist mints not yeat active");
require(amount > 0 && amount <= 5, "5 max mints per tx");
require(minted + amount <= paidTokens, "All sale tokens minted");
require(amount * whitelistPrice == msg.value, "Invalid payment amount");
require(
MerkleProof.verify(_merkleProof, merkleRoot, leaf),
"Not on the list"
);
require(_WLmints[msg.sender] + amount <= 5, "limit 5 per whitelist");
_WLmints[msg.sender] += uint8(amount);
uint256 seed;
address origin = tx.origin;
bytes32 blockies = blockhash(block.number - 1);
bytes32 sauce = entropySauce;
uint256 blockTime = block.timestamp;
uint16[] memory tokenIds = new uint16[](amount);
for (uint256 i = 0; i < amount; i++) {
minted++;
seed = random(origin, blockies, sauce, minted, blockTime);
tokenIds[i] = minted;
colonistNFT._mintColonist(msg.sender, seed);
}
emit newUser(msg.sender);
}
function mintColonist(uint256 amount)
external
payable
noCheaters
whenNotPaused
{
uint16 minted = colonistNFT.minted();
require(amount > 0 && amount <= 5, "5 max mints per tx");
require(minted + amount <= paidTokens, "All sale tokens minted");
require(hasPublicSaleStarted == true, "Public sale not open");
require(msg.value >= amount * publicPrice, "Invalid Payment amount");
uint256 seed;
address origin = tx.origin;
bytes32 blockies = blockhash(block.number - 1);
bytes32 sauce = entropySauce;
uint256 blockTime = block.timestamp;
uint16[] memory tokenIds = new uint16[](amount);
for (uint256 i = 0; i < amount; i++) {
minted++;
seed = random(origin, blockies, sauce, minted, blockTime);
tokenIds[i] = minted;
colonistNFT._mintColonist(msg.sender, seed);
}
emit newUser(msg.sender);
}
function mintToHonors(uint256 amount, address recipient)
external
onlyOwner
{
uint16 minted = colonistNFT.minted();
require(minted + amount <= 1000, "Honor tokens have been sent");
uint16[] memory tokenIds = new uint16[](amount);
uint256 seed;
address origin = tx.origin;
bytes32 blockies = blockhash(block.number - 1);
bytes32 sauce = entropySauce;
uint256 blockTime = block.timestamp;
for (uint256 i = 0; i < amount; i++) {
minted++;
seed = random(origin, blockies, sauce, minted, blockTime);
tokenIds[i] = minted;
colonistNFT._mintToHonors(address(recipient), seed);
}
emit newUser(recipient);
}
function revealHonors() external noCheaters {
require(isHonorsActive == true, "Honor mints have not been activated");
require(
_honorsAddresses[msg.sender].isHonorsMember,
"Not an honors student"
);
require(
_honorsAddresses[msg.sender].hasClaimed == false,
"Already claimed"
);
uint8 id = _honorsAddresses[msg.sender].honorsId;
_honorsAddresses[msg.sender].hasClaimed = true;
colonistNFT._mintHonors(msg.sender, id);
emit newUser(msg.sender);
}
function addToHonorslist(address honorsAddress, uint8 honorsId)
external
onlyOwner
{
_honorsAddresses[honorsAddress] = HonorsList({
isHonorsMember: true,
hasClaimed: false,
honorsId: honorsId
});
}
function togglePublicSale(bool startPublicSale) external onlyOwner {
hasPublicSaleStarted = startPublicSale;
}
function toggleHonorsActive(bool _honorsActive) external onlyOwner {
isHonorsActive = _honorsActive;
}
function toggleWLactive(bool _isWLactive) external onlyOwner {
isWLactive = _isWLactive;
}
function setPaused(bool _paused) external requireContractsSet onlyOwner {
if (_paused) _pause();
else _unpause();
}
function addAdmin(address addr) external onlyOwner {
admins[addr] = true;
}
function removeAdmin(address addr) external onlyOwner {
admins[addr] = false;
}
function random(
address origin,
bytes32 blockies,
bytes32 sauce,
uint16 seed,
uint256 blockTime
) internal pure returns (uint256) {
return
uint256(
keccak256(
abi.encodePacked(origin, blockies, blockTime, sauce, seed)
)
);
}
function setImperialGuildTreasury(address payable _ImperialGuildTreasury)
external
onlyOwner
{
ImperialGuildTreasury = _ImperialGuildTreasury;
}
function withdraw() external onlyOwner {
payable(ImperialGuildTreasury).transfer(address(this).balance);
}
}
{
"compilationTarget": {
"contracts/ShatteredWL.sol": "ShatteredWL"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"details": {
"constantOptimizer": true,
"cse": true,
"deduplicate": true,
"inliner": true,
"jumpdestRemover": true,
"orderLiterals": true,
"peephole": true,
"yul": true,
"yulDetails": {
"optimizerSteps": "dhfoDgvulfnTUtnIf",
"stackAllocation": true
}
},
"runs": 2000
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newUser","type":"address"}],"name":"newUser","type":"event"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32[]","name":"_merkleProof","type":"bytes32[]"}],"name":"WlMintColonist","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"addAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"honorsAddress","type":"address"},{"internalType":"uint8","name":"honorsId","type":"uint8"}],"name":"addToHonorslist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"auth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"colonistNFT","outputs":[{"internalType":"contract IColonist","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasPublicSaleStarted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isHonorsActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isWLactive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mintColonist","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"mintToHonors","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paidTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"publicPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"removeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revealHonors","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_colonistNFT","type":"address"}],"name":"setContracts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_ImperialGuildTreasury","type":"address"}],"name":"setImperialGuildTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_honorsActive","type":"bool"}],"name":"toggleHonorsActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"startPublicSale","type":"bool"}],"name":"togglePublicSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isWLactive","type":"bool"}],"name":"toggleWLactive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"whitelistPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]