pragma solidity ^0.8.14;
contract MainnetNFTCounter {
address public immutable dev;
uint64 public constant EVOTURES_PRICE = 0.04 ether;
uint64 public constant BOOSTER_PRICE = 0.006 ether;
struct UserInfo {
uint8 boosters;
uint8 evotures;
}
mapping(address => UserInfo) public userInfo;
constructor() {
dev = msg.sender;
}
function buy(uint8 _evotures, uint8 _boosters) external payable {
require(msg.value >= (_evotures*EVOTURES_PRICE + _evotures*_boosters*BOOSTER_PRICE), "EvoturesNFT::buy: INSUFFICIENT_ETH");
require(_evotures <= (3 - userInfo[msg.sender].evotures) && _boosters <= 5, "EvoturesNFT::buy: FORBIDDEN");
userInfo[msg.sender].evotures += _evotures;
userInfo[msg.sender].boosters += _evotures*_boosters;
}
function withdrawETH() external {
// Withdraw raised eth
require (msg.sender == dev, "EvoturesNFT::withdrawETH: CALLER_NOT_DEV");
(bool success, ) = payable(msg.sender).call{value: address(this).balance}("");
require(success, "EvoturesNFT::withdrawETH: TRANSFER_FAILED");
}
receive() external payable {}
}
{
"compilationTarget": {
"contracts/MainnetNFTCounter.sol": "MainnetNFTCounter"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BOOSTER_PRICE","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EVOTURES_PRICE","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"_evotures","type":"uint8"},{"internalType":"uint8","name":"_boosters","type":"uint8"}],"name":"buy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"dev","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint8","name":"boosters","type":"uint8"},{"internalType":"uint8","name":"evotures","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]