文件 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:EVOWAREAuctionWhitelistSale.sol
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
abstract contract EVOWARE {
function mint(
uint256 tknId,
uint256 n,
address to
) public payable virtual returns (uint256);
}
contract EVOWAREAuctionWhitelistSale is Ownable, ReentrancyGuard {
uint256 public constant MAX_SUPPLY = 729;
uint256 public maxWhitelistAmount = 21;
uint256 public immutable maxWhitelistPerAddressAmount = 1;
uint256 public constant whitelistSalePrice = 0.69 ether;
uint256 public auctionMaxMintAmount = 371;
uint256 public lastAuctionPrice = 2 ether;
uint256 public constant auctionStartPrice = 2 ether;
uint256 public constant auctionMinPrice = 0.8 ether;
uint256 public constant auctionRate = 0.1 ether;
uint256 public constant autcionTimeRate = 5 * 1 minutes;
bytes32 public whitelistMerkleRoot;
uint64 public immutable whitelistStartTime = 1648274400;
uint64 public immutable whitelistEndTime = 1648310400;
uint64 public immutable auctionStartTime = 1648360800;
uint64 public immutable auctionEndTime = 1648396800;
mapping(address => uint256) public whitelistMinted;
uint256 public whitelistMintedAmount;
uint256 public auctionMintedAmount;
address EVOWARETokenAddress;
address withdrawAddress;
constructor() {}
modifier isValidMerkleProof(bytes32[] calldata merkleProof, bytes32 root) {
require(
MerkleProof.verify(
merkleProof,
root,
keccak256(abi.encodePacked(msg.sender))
),
"Address does not exist in list"
);
_;
}
modifier isCorrectPayment(uint256 price, uint256 numberOfTokens) {
require(
price * numberOfTokens == msg.value,
"Incorrect ETH value sent"
);
_;
}
modifier canWhitelistMint(uint256 numberOfTokens) {
uint256 ts = whitelistMintedAmount;
require(
ts + numberOfTokens <= maxWhitelistAmount,
"Purchase would exceed max whitelist round tokens"
);
_;
}
modifier canAuctionMint(uint256 n) {
uint256 ts = auctionMintedAmount;
require(
ts + n <= auctionMaxMintAmount,
"Purchase would exceed max auction mint amount"
);
_;
}
modifier checkWhitelistTime() {
require(
block.timestamp >= uint256(whitelistStartTime) &&
block.timestamp <= uint256(whitelistEndTime),
"Outside whitelist round hours"
);
_;
}
modifier checkAuctionTime() {
require(
block.timestamp >= uint256(auctionStartTime) &&
block.timestamp <= uint256(auctionEndTime),
"Outside autcion round hours"
);
_;
}
function mintAuction()
public
payable
canAuctionMint(1)
checkAuctionTime
nonReentrant
{
uint256 price = getAuctionPrice();
if (price != lastAuctionPrice) {
lastAuctionPrice = price;
}
require(msg.value >= price, "Incorrect ETH value sent");
if (msg.value > price) {
payable(msg.sender).transfer(msg.value - price);
}
EVOWARE tokenAttribution = EVOWARE(EVOWARETokenAddress);
tokenAttribution.mint(0, 1, msg.sender);
++auctionMintedAmount;
}
function mintWhitelist(uint256 n, bytes32[] calldata merkleProof)
public
payable
isValidMerkleProof(merkleProof, whitelistMerkleRoot)
isCorrectPayment(whitelistSalePrice, n)
canWhitelistMint(n)
checkWhitelistTime
nonReentrant
{
require(
whitelistMinted[msg.sender] + n <= maxWhitelistPerAddressAmount,
"EVOWARE is already exceed max mint amount by this wallet at whitelist round"
);
EVOWARE tokenAttribution = EVOWARE(EVOWARETokenAddress);
tokenAttribution.mint(0, n, msg.sender);
whitelistMinted[msg.sender] += n;
whitelistMintedAmount += n;
}
function getAuctionPrice() public view returns (uint256) {
uint256 timeElapsed = block.timestamp - auctionStartTime;
uint256 discount = auctionRate * (timeElapsed / autcionTimeRate);
if (discount > auctionStartPrice - auctionMinPrice) {
discount = auctionStartPrice - auctionMinPrice;
}
uint256 price = auctionStartPrice - discount;
return price;
}
function withdraw() public {
require(msg.sender == withdrawAddress, "not withdrawAddress");
uint256 balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
function withdrawTokens(IERC20 token) public {
require(msg.sender == withdrawAddress, "not withdrawAddress");
uint256 balance = token.balanceOf(address(this));
token.transfer(msg.sender, balance);
}
function setWhitelistMerkleRoot(bytes32 merkleRoot) external onlyOwner {
whitelistMerkleRoot = merkleRoot;
}
function setEVOWARETokenAddress(address newAddress) public onlyOwner {
EVOWARETokenAddress = newAddress;
}
function setWithdrawAddress(address newAddress) public onlyOwner {
withdrawAddress = newAddress;
}
function setAuctionMaxMintAmount(uint256 newAmount) public onlyOwner {
auctionMaxMintAmount = newAmount;
}
function setWhitelistMaxMintAmount(uint256 newAmount) public onlyOwner {
maxWhitelistAmount = newAmount;
}
}
文件 3 的 7:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 4 的 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 = _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 的 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);
}
}
文件 6 的 7:ReentrancyGuard.sol
pragma solidity ^0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
文件 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/EVOWAREAuctionWhitelistSale.sol": "EVOWAREAuctionWhitelistSale"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"MAX_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionEndTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionMaxMintAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionMinPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionMintedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionStartPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionStartTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"autcionTimeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAuctionPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastAuctionPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWhitelistAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWhitelistPerAddressAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintAuction","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"n","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"name":"mintWhitelist","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"setAuctionMaxMintAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"setEVOWARETokenAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"setWhitelistMaxMintAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"name":"setWhitelistMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"setWithdrawAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"whitelistEndTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"whitelistMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"whitelistMintedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"whitelistSalePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"whitelistStartTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"}]