编译器
0.8.10+commit.fc410830
文件 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:ECDSA.sol
pragma solidity ^0.8.0;
import "../Strings.sol";
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return;
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
文件 3 的 7: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 = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
}
文件 4 的 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);
}
}
文件 5 的 7:SafeMath.sol
pragma solidity ^0.8.0;
library SafeMath {
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
文件 6 的 7:SlotiePreSale.sol
pragma solidity 0.8.10;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
interface SlotieNFT {
function mintTo(uint256, address) external;
}
contract SlotiePreSale is Ownable {
using SafeMath for uint256;
using Strings for uint256;
using ECDSA for bytes32;
SlotieNFT public slotieNFT;
bool public phaseOneActive = false;
bool public phaseTwoActive = false;
uint256 public constant maxSupply = 2501;
uint256 public constant ticketsPerUser = 3;
uint256 public constant ticketPrice = 0.08 ether;
uint256 public ticketSales = 1;
mapping(address => uint256) public addressToTickets;
bytes32 public phaseOneMerkleRoot = 0x5406f95cc1896abac2d843cd72298f3d6072f06941ef21e103d6bcae59807df0;
bytes32 public phaseTwoMerkleRoot = 0x74a7375e09ffd2a49c6cfe5325df5afb05b87dfd3dbfb2708c140e805b89ad0e;
bytes32 public giveawayMerkleRoot = 0xef7d2b691d30203e53e5df4f3d16f015208170d6d468f9af39a8d7ef2a12b424;
uint256 public giveAwaySupply = 350;
mapping(address => uint256) public addressToTicketMints;
mapping(address => uint256) public addressToGiveawayMints;
event SetSlotieNFT(address _slotieNFT);
event SetSignatureProvider(address _provider);
event MakePhaseOneActive(bool _active);
event MakePhaseTwoActive(bool _active);
event MintSloties(address _sender, uint256 _amount);
constructor(
address _sloties
) Ownable() {
slotieNFT = SlotieNFT(_sloties);
}
function setSlotieNFT(SlotieNFT _slotieNFT) external onlyOwner {
slotieNFT = _slotieNFT;
emit SetSlotieNFT(address(_slotieNFT));
}
function setPhaseOneMerkleRoot(bytes32 _root) external onlyOwner {
phaseOneMerkleRoot = _root;
}
function setPhaseTwoMerkleRoot(bytes32 _root) external onlyOwner {
phaseTwoMerkleRoot = _root;
}
function setGiveAwayMerkleRoot(bytes32 _root) external onlyOwner {
giveawayMerkleRoot = _root;
}
function makePhaseOneActive(bool _val) external onlyOwner {
phaseOneActive = _val;
emit MakePhaseOneActive(_val);
}
function makePhaseTwoActive(bool _val) external onlyOwner {
phaseTwoActive = _val;
emit MakePhaseTwoActive(_val);
}
function phaseOneBuyTicketsMerkle(
bytes32[] calldata proof
) external payable {
require(phaseOneActive, "PHASE ONE NOT ACTIVE");
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
require(MerkleProof.verify(proof, phaseOneMerkleRoot, leaf), "INVALID PROOF");
require(addressToTickets[msg.sender] == 0, "ALREADY GOT TICKET");
require(msg.value == ticketPrice, "INCORRECT AMOUNT PAID");
addressToTickets[msg.sender] = 1;
ticketSales = ticketSales.add(1);
}
function phaseTwoBuyTicketsMerkle(
uint256 _amount,
bytes32[] calldata proof
) external payable {
require(phaseTwoActive, "PHASE TWO NOT ACTIVE");
require(_amount > 0, "HAVE TO BUY AT LEAST 1");
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
require(MerkleProof.verify(proof, phaseTwoMerkleRoot, leaf), "INVALID PROOF");
require(addressToTickets[msg.sender].add(_amount) <= ticketsPerUser, "ALREADY GOT TICKET");
require(ticketSales.add(_amount) <= maxSupply, "MAX TICKETS SOLD");
require(msg.value == ticketPrice.mul(_amount), "INCORRECT AMOUNT PAID");
addressToTickets[msg.sender] = addressToTickets[msg.sender].add(_amount);
ticketSales = ticketSales.add(_amount);
}
function mintSloties() external {
uint256 ticketsOfSender = addressToTickets[msg.sender];
uint256 mintsOfSender = addressToTicketMints[msg.sender];
uint256 mintable = ticketsOfSender.sub(mintsOfSender);
require(mintable > 0, "NO MINTABLE TICKETS");
addressToTicketMints[msg.sender] = addressToTicketMints[msg.sender].add(mintable);
slotieNFT.mintTo(mintable, msg.sender);
emit MintSloties(msg.sender, mintable);
}
function claimGiveaway(uint256 _amount, bytes32[] calldata proof) external {
require(_amount > 0, "HAVE TO BUY AT LEAST 1");
bytes32 leaf = keccak256(abi.encodePacked(msg.sender, _amount));
require(MerkleProof.verify(proof, giveawayMerkleRoot, leaf), "INVALID PROOF");
uint256 giveAwayMints = addressToGiveawayMints[msg.sender];
require(giveAwayMints == 0, "ALREADY CLAIMED");
addressToGiveawayMints[msg.sender] = addressToGiveawayMints[msg.sender].add(_amount);
slotieNFT.mintTo(_amount, msg.sender);
}
function withdraw() external onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
}
文件 7 的 7: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": {
"contracts/SlotiePreSale.sol": "SlotiePreSale"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 1000
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_sloties","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_active","type":"bool"}],"name":"MakePhaseOneActive","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_active","type":"bool"}],"name":"MakePhaseTwoActive","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"MintSloties","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":"_provider","type":"address"}],"name":"SetSignatureProvider","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_slotieNFT","type":"address"}],"name":"SetSlotieNFT","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"addressToGiveawayMints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"addressToTicketMints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"addressToTickets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"claimGiveaway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"giveAwaySupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"giveawayMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_val","type":"bool"}],"name":"makePhaseOneActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_val","type":"bool"}],"name":"makePhaseTwoActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintSloties","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"phaseOneActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"phaseOneBuyTicketsMerkle","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"phaseOneMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"phaseTwoActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"phaseTwoBuyTicketsMerkle","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"phaseTwoMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_root","type":"bytes32"}],"name":"setGiveAwayMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_root","type":"bytes32"}],"name":"setPhaseOneMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_root","type":"bytes32"}],"name":"setPhaseTwoMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract SlotieNFT","name":"_slotieNFT","type":"address"}],"name":"setSlotieNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slotieNFT","outputs":[{"internalType":"contract SlotieNFT","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticketPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticketSales","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticketsPerUser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]