|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.1; |
|
|
|
|
|
|
|
|
|
library Address { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isContract(address account) internal view returns (bool) { |
|
|
|
|
|
|
|
|
|
return account.code.length > 0; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sendValue(address payable recipient, uint256 amount) internal { |
|
require(address(this).balance >= amount, "Address: insufficient balance"); |
|
|
|
(bool success, ) = recipient.call{value: amount}(""); |
|
require(success, "Address: unable to send value, recipient may have reverted"); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function functionCall(address target, bytes memory data) internal returns (bytes memory) { |
|
return functionCall(target, data, "Address: low-level call failed"); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function functionCall( |
|
address target, |
|
bytes memory data, |
|
string memory errorMessage |
|
) internal returns (bytes memory) { |
|
return functionCallWithValue(target, data, 0, errorMessage); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function functionCallWithValue( |
|
address target, |
|
bytes memory data, |
|
uint256 value |
|
) internal returns (bytes memory) { |
|
return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function functionCallWithValue( |
|
address target, |
|
bytes memory data, |
|
uint256 value, |
|
string memory errorMessage |
|
) internal returns (bytes memory) { |
|
require(address(this).balance >= value, "Address: insufficient balance for call"); |
|
require(isContract(target), "Address: call to non-contract"); |
|
|
|
(bool success, bytes memory returndata) = target.call{value: value}(data); |
|
return verifyCallResult(success, returndata, errorMessage); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { |
|
return functionStaticCall(target, data, "Address: low-level static call failed"); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function functionStaticCall( |
|
address target, |
|
bytes memory data, |
|
string memory errorMessage |
|
) internal view returns (bytes memory) { |
|
require(isContract(target), "Address: static call to non-contract"); |
|
|
|
(bool success, bytes memory returndata) = target.staticcall(data); |
|
return verifyCallResult(success, returndata, errorMessage); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { |
|
return functionDelegateCall(target, data, "Address: low-level delegate call failed"); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function functionDelegateCall( |
|
address target, |
|
bytes memory data, |
|
string memory errorMessage |
|
) internal returns (bytes memory) { |
|
require(isContract(target), "Address: delegate call to non-contract"); |
|
|
|
(bool success, bytes memory returndata) = target.delegatecall(data); |
|
return verifyCallResult(success, returndata, errorMessage); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function verifyCallResult( |
|
bool success, |
|
bytes memory returndata, |
|
string memory errorMessage |
|
) internal pure returns (bytes memory) { |
|
if (success) { |
|
return returndata; |
|
} else { |
|
|
|
if (returndata.length > 0) { |
|
|
|
|
|
assembly { |
|
let returndata_size := mload(returndata) |
|
revert(add(32, returndata), returndata_size) |
|
} |
|
} else { |
|
revert(errorMessage); |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC721Receiver { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onERC721Received( |
|
address operator, |
|
address from, |
|
uint256 tokenId, |
|
bytes calldata data |
|
) external returns (bytes4); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC165 { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function supportsInterface(bytes4 interfaceId) external view returns (bool); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract contract ERC165 is IERC165 { |
|
|
|
|
|
|
|
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { |
|
return interfaceId == type(IERC165).interfaceId; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
|
|
|
|
|
|
|
|
interface IERC721 is IERC165 { |
|
|
|
|
|
|
|
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); |
|
|
|
|
|
|
|
|
|
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); |
|
|
|
|
|
|
|
|
|
event ApprovalForAll(address indexed owner, address indexed operator, bool approved); |
|
|
|
|
|
|
|
|
|
function balanceOf(address owner) external view returns (uint256 balance); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ownerOf(uint256 tokenId) external view returns (address owner); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function safeTransferFrom( |
|
address from, |
|
address to, |
|
uint256 tokenId |
|
) external; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function transferFrom( |
|
address from, |
|
address to, |
|
uint256 tokenId |
|
) external; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function approve(address to, uint256 tokenId) external; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getApproved(uint256 tokenId) external view returns (address operator); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setApprovalForAll(address operator, bool _approved) external; |
|
|
|
|
|
|
|
|
|
|
|
|
|
function isApprovedForAll(address owner, address operator) external view returns (bool); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function safeTransferFrom( |
|
address from, |
|
address to, |
|
uint256 tokenId, |
|
bytes calldata data |
|
) external; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC721Enumerable is IERC721 { |
|
|
|
|
|
|
|
function totalSupply() external view returns (uint256); |
|
|
|
|
|
|
|
|
|
|
|
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); |
|
|
|
|
|
|
|
|
|
|
|
function tokenByIndex(uint256 index) external view returns (uint256); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC721Metadata is IERC721 { |
|
|
|
|
|
|
|
function name() external view returns (string memory); |
|
|
|
|
|
|
|
|
|
function symbol() external view returns (string memory); |
|
|
|
|
|
|
|
|
|
function tokenURI(uint256 tokenId) external view returns (string memory); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract contract Teams is Ownable{ |
|
mapping (address => bool) internal team; |
|
|
|
|
|
|
|
|
|
|
|
function addToTeam(address _address) public onlyOwner { |
|
require(_address != address(0), "Invalid address"); |
|
require(!inTeam(_address), "This address is already in your team."); |
|
|
|
team[_address] = true; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function removeFromTeam(address _address) public onlyOwner { |
|
require(_address != address(0), "Invalid address"); |
|
require(inTeam(_address), "This address is not in your team currently."); |
|
|
|
team[_address] = false; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function inTeam(address _address) |
|
public |
|
view |
|
returns (bool) |
|
{ |
|
require(_address != address(0), "Invalid address to check."); |
|
return team[_address] == true; |
|
} |
|
|
|
|
|
|
|
|
|
modifier onlyTeamOrOwner() { |
|
bool _isOwner = owner() == _msgSender(); |
|
bool _isTeam = inTeam(_msgSender()); |
|
require(_isOwner || _isTeam, "Team: caller is not the owner or in Team."); |
|
_; |
|
} |
|
} |
|
|
|
|
|
|
|
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) |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
abstract contract Allowlist is Teams { |
|
bytes32 public merkleRoot; |
|
bool public onlyAllowlistMode = false; |
|
|
|
|
|
|
|
|
|
|
|
function updateMerkleRoot(bytes32 _newMerkleRoot) public onlyTeamOrOwner { |
|
require(_newMerkleRoot != merkleRoot, "Merkle root will be unchanged!"); |
|
merkleRoot = _newMerkleRoot; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
function isAllowlisted(address _to, bytes32[] calldata _merkleProof) public view returns(bool) { |
|
require(merkleRoot != 0, "Merkle root is not set!"); |
|
bytes32 leaf = keccak256(abi.encodePacked(_to)); |
|
|
|
return MerkleProof.verify(_merkleProof, merkleRoot, leaf); |
|
} |
|
|
|
|
|
function enableAllowlistOnlyMode() public onlyTeamOrOwner { |
|
onlyAllowlistMode = true; |
|
} |
|
|
|
function disableAllowlistOnlyMode() public onlyTeamOrOwner { |
|
onlyAllowlistMode = false; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contract ERC721A is |
|
Context, |
|
ERC165, |
|
IERC721, |
|
IERC721Metadata, |
|
IERC721Enumerable, |
|
Teams |
|
{ |
|
using Address for address; |
|
using Strings for uint256; |
|
|
|
struct TokenOwnership { |
|
address addr; |
|
uint64 startTimestamp; |
|
} |
|
|
|
struct AddressData { |
|
uint128 balance; |
|
uint128 numberMinted; |
|
} |
|
|
|
uint256 private currentIndex; |
|
|
|
uint256 public immutable collectionSize; |
|
uint256 public maxBatchSize; |
|
|
|
|
|
string private _name; |
|
|
|
|
|
string private _symbol; |
|
|
|
|
|
|
|
mapping(uint256 => TokenOwnership) private _ownerships; |
|
|
|
|
|
mapping(address => AddressData) private _addressData; |
|
|
|
|
|
mapping(uint256 => address) private _tokenApprovals; |
|
|
|
|
|
mapping(address => mapping(address => bool)) private _operatorApprovals; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mapping(address => bool) public restrictedApprovalAddresses; |
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor( |
|
string memory name_, |
|
string memory symbol_, |
|
uint256 maxBatchSize_, |
|
uint256 collectionSize_ |
|
) { |
|
require( |
|
collectionSize_ > 0, |
|
"ERC721A: collection must have a nonzero supply" |
|
); |
|
require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); |
|
_name = name_; |
|
_symbol = symbol_; |
|
maxBatchSize = maxBatchSize_; |
|
collectionSize = collectionSize_; |
|
currentIndex = _startTokenId(); |
|
} |
|
|
|
|
|
|
|
|
|
function _startTokenId() internal view virtual returns (uint256) { |
|
return 1; |
|
} |
|
|
|
|
|
|
|
|
|
function totalSupply() public view override returns (uint256) { |
|
return _totalMinted(); |
|
} |
|
|
|
function currentTokenId() public view returns (uint256) { |
|
return _totalMinted(); |
|
} |
|
|
|
function getNextTokenId() public view returns (uint256) { |
|
return _totalMinted() + 1; |
|
} |
|
|
|
|
|
|
|
|
|
function _totalMinted() internal view returns (uint256) { |
|
unchecked { |
|
return currentIndex - _startTokenId(); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
function tokenByIndex(uint256 index) public view override returns (uint256) { |
|
require(index < totalSupply(), "ERC721A: global index out of bounds"); |
|
return index; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
function tokenOfOwnerByIndex(address owner, uint256 index) |
|
public |
|
view |
|
override |
|
returns (uint256) |
|
{ |
|
require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); |
|
uint256 numMintedSoFar = totalSupply(); |
|
uint256 tokenIdsIdx = 0; |
|
address currOwnershipAddr = address(0); |
|
for (uint256 i = 0; i < numMintedSoFar; i++) { |
|
TokenOwnership memory ownership = _ownerships[i]; |
|
if (ownership.addr != address(0)) { |
|
currOwnershipAddr = ownership.addr; |
|
} |
|
if (currOwnershipAddr == owner) { |
|
if (tokenIdsIdx == index) { |
|
return i; |
|
} |
|
tokenIdsIdx++; |
|
} |
|
} |
|
revert("ERC721A: unable to get token of owner by index"); |
|
} |
|
|
|
|
|
|
|
|
|
function supportsInterface(bytes4 interfaceId) |
|
public |
|
view |
|
virtual |
|
override(ERC165, IERC165) |
|
returns (bool) |
|
{ |
|
return |
|
interfaceId == type(IERC721).interfaceId || |
|
interfaceId == type(IERC721Metadata).interfaceId || |
|
interfaceId == type(IERC721Enumerable).interfaceId || |
|
super.supportsInterface(interfaceId); |
|
} |
|
|
|
|
|
|
|
|
|
function balanceOf(address owner) public view override returns (uint256) { |
|
require(owner != address(0), "ERC721A: balance query for the zero address"); |
|
return uint256(_addressData[owner].balance); |
|
} |
|
|
|
function _numberMinted(address owner) internal view returns (uint256) { |
|
require( |
|
owner != address(0), |
|
"ERC721A: number minted query for the zero address" |
|
); |
|
return uint256(_addressData[owner].numberMinted); |
|
} |
|
|
|
function ownershipOf(uint256 tokenId) |
|
internal |
|
view |
|
returns (TokenOwnership memory) |
|
{ |
|
uint256 curr = tokenId; |
|
|
|
unchecked { |
|
if (_startTokenId() <= curr && curr < currentIndex) { |
|
TokenOwnership memory ownership = _ownerships[curr]; |
|
if (ownership.addr != address(0)) { |
|
return ownership; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (true) { |
|
curr--; |
|
ownership = _ownerships[curr]; |
|
if (ownership.addr != address(0)) { |
|
return ownership; |
|
} |
|
} |
|
} |
|
} |
|
|
|
revert("ERC721A: unable to determine the owner of token"); |
|
} |
|
|
|
|
|
|
|
|
|
function ownerOf(uint256 tokenId) public view override returns (address) { |
|
return ownershipOf(tokenId).addr; |
|
} |
|
|
|
|
|
|
|
|
|
function name() public view virtual override returns (string memory) { |
|
return _name; |
|
} |
|
|
|
|
|
|
|
|
|
function symbol() public view virtual override returns (string memory) { |
|
return _symbol; |
|
} |
|
|
|
|
|
|
|
|
|
function tokenURI(uint256 tokenId) |
|
public |
|
view |
|
virtual |
|
override |
|
returns (string memory) |
|
{ |
|
string memory baseURI = _baseURI(); |
|
return |
|
bytes(baseURI).length > 0 |
|
? string(abi.encodePacked(baseURI, tokenId.toString())) |
|
: ""; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
function _baseURI() internal view virtual returns (string memory) { |
|
return ""; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setApprovalRestriction(address _address, bool _isRestricted) public onlyTeamOrOwner { |
|
restrictedApprovalAddresses[_address] = _isRestricted; |
|
} |
|
|
|
|
|
|
|
|
|
function approve(address to, uint256 tokenId) public override { |
|
address owner = ERC721A.ownerOf(tokenId); |
|
require(to != owner, "ERC721A: approval to current owner"); |
|
require(restrictedApprovalAddresses[to] == false, "ERC721RestrictedApproval: Address to approve has been restricted by contract owner and is not allowed to be marked for approval"); |
|
|
|
require( |
|
_msgSender() == owner || isApprovedForAll(owner, _msgSender()), |
|
"ERC721A: approve caller is not owner nor approved for all" |
|
); |
|
|
|
_approve(to, tokenId, owner); |
|
} |
|
|
|
|
|
|
|
|
|
function getApproved(uint256 tokenId) public view override returns (address) { |
|
require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); |
|
|
|
return _tokenApprovals[tokenId]; |
|
} |
|
|
|
|
|
|
|
|
|
function setApprovalForAll(address operator, bool approved) public override { |
|
require(operator != _msgSender(), "ERC721A: approve to caller"); |
|
require(restrictedApprovalAddresses[operator] == false, "ERC721RestrictedApproval: Operator address has been restricted by contract owner and is not allowed to be marked for approval"); |
|
|
|
_operatorApprovals[_msgSender()][operator] = approved; |
|
emit ApprovalForAll(_msgSender(), operator, approved); |
|
} |
|
|
|
|
|
|
|
|
|
function isApprovedForAll(address owner, address operator) |
|
public |
|
view |
|
virtual |
|
override |
|
returns (bool) |
|
{ |
|
return _operatorApprovals[owner][operator]; |
|
} |
|
|
|
|
|
|
|
|
|
function transferFrom( |
|
address from, |
|
address to, |
|
uint256 tokenId |
|
) public override { |
|
_transfer(from, to, tokenId); |
|
} |
|
|
|
|
|
|
|
|
|
function safeTransferFrom( |
|
address from, |
|
address to, |
|
uint256 tokenId |
|
) public override { |
|
safeTransferFrom(from, to, tokenId, ""); |
|
} |
|
|
|
|
|
|
|
|
|
function safeTransferFrom( |
|
address from, |
|
address to, |
|
uint256 tokenId, |
|
bytes memory _data |
|
) public override { |
|
_transfer(from, to, tokenId); |
|
require( |
|
_checkOnERC721Received(from, to, tokenId, _data), |
|
"ERC721A: transfer to non ERC721Receiver implementer" |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _exists(uint256 tokenId) internal view returns (bool) { |
|
return _startTokenId() <= tokenId && tokenId < currentIndex; |
|
} |
|
|
|
function _safeMint(address to, uint256 quantity, bool isAdminMint) internal { |
|
_safeMint(to, quantity, isAdminMint, ""); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _safeMint( |
|
address to, |
|
uint256 quantity, |
|
bool isAdminMint, |
|
bytes memory _data |
|
) internal { |
|
uint256 startTokenId = currentIndex; |
|
require(to != address(0), "ERC721A: mint to the zero address"); |
|
|
|
require(!_exists(startTokenId), "ERC721A: token already minted"); |
|
|
|
|
|
if (isAdminMint == false) { |
|
require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high"); |
|
} |
|
|
|
_beforeTokenTransfers(address(0), to, startTokenId, quantity); |
|
|
|
AddressData memory addressData = _addressData[to]; |
|
_addressData[to] = AddressData( |
|
addressData.balance + uint128(quantity), |
|
addressData.numberMinted + (isAdminMint ? 0 : uint128(quantity)) |
|
); |
|
_ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); |
|
|
|
uint256 updatedIndex = startTokenId; |
|
|
|
for (uint256 i = 0; i < quantity; i++) { |
|
emit Transfer(address(0), to, updatedIndex); |
|
require( |
|
_checkOnERC721Received(address(0), to, updatedIndex, _data), |
|
"ERC721A: transfer to non ERC721Receiver implementer" |
|
); |
|
updatedIndex++; |
|
} |
|
|
|
currentIndex = updatedIndex; |
|
_afterTokenTransfers(address(0), to, startTokenId, quantity); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _transfer( |
|
address from, |
|
address to, |
|
uint256 tokenId |
|
) private { |
|
TokenOwnership memory prevOwnership = ownershipOf(tokenId); |
|
|
|
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || |
|
getApproved(tokenId) == _msgSender() || |
|
isApprovedForAll(prevOwnership.addr, _msgSender())); |
|
|
|
require( |
|
isApprovedOrOwner, |
|
"ERC721A: transfer caller is not owner nor approved" |
|
); |
|
|
|
require( |
|
prevOwnership.addr == from, |
|
"ERC721A: transfer from incorrect owner" |
|
); |
|
require(to != address(0), "ERC721A: transfer to the zero address"); |
|
|
|
_beforeTokenTransfers(from, to, tokenId, 1); |
|
|
|
|
|
_approve(address(0), tokenId, prevOwnership.addr); |
|
|
|
_addressData[from].balance -= 1; |
|
_addressData[to].balance += 1; |
|
_ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp)); |
|
|
|
|
|
|
|
uint256 nextTokenId = tokenId + 1; |
|
if (_ownerships[nextTokenId].addr == address(0)) { |
|
if (_exists(nextTokenId)) { |
|
_ownerships[nextTokenId] = TokenOwnership( |
|
prevOwnership.addr, |
|
prevOwnership.startTimestamp |
|
); |
|
} |
|
} |
|
|
|
emit Transfer(from, to, tokenId); |
|
_afterTokenTransfers(from, to, tokenId, 1); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
function _approve( |
|
address to, |
|
uint256 tokenId, |
|
address owner |
|
) private { |
|
_tokenApprovals[tokenId] = to; |
|
emit Approval(owner, to, tokenId); |
|
} |
|
|
|
uint256 public nextOwnerToExplicitlySet = 0; |
|
|
|
|
|
|
|
|
|
function _setOwnersExplicit(uint256 quantity) internal { |
|
uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; |
|
require(quantity > 0, "quantity must be nonzero"); |
|
if (currentIndex == _startTokenId()) revert('No Tokens Minted Yet'); |
|
|
|
uint256 endIndex = oldNextOwnerToSet + quantity - 1; |
|
if (endIndex > collectionSize - 1) { |
|
endIndex = collectionSize - 1; |
|
} |
|
|
|
require(_exists(endIndex), "not enough minted yet for this cleanup"); |
|
for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { |
|
if (_ownerships[i].addr == address(0)) { |
|
TokenOwnership memory ownership = ownershipOf(i); |
|
_ownerships[i] = TokenOwnership( |
|
ownership.addr, |
|
ownership.startTimestamp |
|
); |
|
} |
|
} |
|
nextOwnerToExplicitlySet = endIndex + 1; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _checkOnERC721Received( |
|
address from, |
|
address to, |
|
uint256 tokenId, |
|
bytes memory _data |
|
) private returns (bool) { |
|
if (to.isContract()) { |
|
try |
|
IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) |
|
returns (bytes4 retval) { |
|
return retval == IERC721Receiver(to).onERC721Received.selector; |
|
} catch (bytes memory reason) { |
|
if (reason.length == 0) { |
|
revert("ERC721A: transfer to non ERC721Receiver implementer"); |
|
} else { |
|
assembly { |
|
revert(add(32, reason), mload(reason)) |
|
} |
|
} |
|
} |
|
} else { |
|
return true; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _beforeTokenTransfers( |
|
address from, |
|
address to, |
|
uint256 startTokenId, |
|
uint256 quantity |
|
) internal virtual {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _afterTokenTransfers( |
|
address from, |
|
address to, |
|
uint256 startTokenId, |
|
uint256 quantity |
|
) internal virtual {} |
|
} |
|
|
|
|
|
|
|
|
|
abstract contract Ramppable { |
|
address public RAMPPADDRESS = 0xa9dAC8f3aEDC55D0FE707B86B8A45d246858d2E1; |
|
|
|
modifier isRampp() { |
|
require(msg.sender == RAMPPADDRESS, "Ownable: caller is not RAMPP"); |
|
_; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
interface IERC20 { |
|
function allowance(address owner, address spender) external view returns (uint256); |
|
function transfer(address _to, uint256 _amount) external returns (bool); |
|
function balanceOf(address account) external view returns (uint256); |
|
function transferFrom(address from, address to, uint256 amount) external returns (bool); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract contract WithdrawableV2 is Teams, Ramppable { |
|
struct acceptedERC20 { |
|
bool isActive; |
|
uint256 chargeAmount; |
|
} |
|
|
|
|
|
mapping(address => acceptedERC20) private allowedTokenContracts; |
|
address[] public payableAddresses = [RAMPPADDRESS,0x919fC964bcf320cFF57fc9f55154Dde756Fb06B7]; |
|
address[] public surchargePayableAddresses = [RAMPPADDRESS]; |
|
address public erc20Payable = 0x919fC964bcf320cFF57fc9f55154Dde756Fb06B7; |
|
uint256[] public payableFees = [5,95]; |
|
uint256[] public surchargePayableFees = [100]; |
|
uint256 public payableAddressCount = 2; |
|
uint256 public surchargePayableAddressCount = 1; |
|
uint256 public ramppSurchargeBalance = 0 ether; |
|
uint256 public ramppSurchargeFee = 0.001 ether; |
|
bool public onlyERC20MintingMode = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function calcAvailableBalance() public view returns(uint256) { |
|
return address(this).balance - ramppSurchargeBalance; |
|
} |
|
|
|
function withdrawAll() public onlyTeamOrOwner { |
|
require(calcAvailableBalance() > 0); |
|
_withdrawAll(); |
|
} |
|
|
|
function withdrawAllRampp() public isRampp { |
|
require(calcAvailableBalance() > 0); |
|
_withdrawAll(); |
|
} |
|
|
|
function _withdrawAll() private { |
|
uint256 balance = calcAvailableBalance(); |
|
|
|
for(uint i=0; i < payableAddressCount; i++ ) { |
|
_widthdraw( |
|
payableAddresses[i], |
|
(balance * payableFees[i]) / 100 |
|
); |
|
} |
|
} |
|
|
|
function _widthdraw(address _address, uint256 _amount) private { |
|
(bool success, ) = _address.call{value: _amount}(""); |
|
require(success, "Transfer failed."); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function _withdrawAllSurcharges() private { |
|
uint256 balance = ramppSurchargeBalance; |
|
if(balance == 0) { return; } |
|
|
|
for(uint i=0; i < surchargePayableAddressCount; i++ ) { |
|
_widthdraw( |
|
surchargePayableAddresses[i], |
|
(balance * surchargePayableFees[i]) / 100 |
|
); |
|
} |
|
ramppSurchargeBalance = 0 ether; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function withdrawERC20(address _tokenContract, uint256 _amountToWithdraw) public onlyTeamOrOwner { |
|
require(_amountToWithdraw > 0); |
|
IERC20 tokenContract = IERC20(_tokenContract); |
|
require(tokenContract.balanceOf(address(this)) >= _amountToWithdraw, "WithdrawV2: Contract does not own enough tokens"); |
|
tokenContract.transfer(erc20Payable, _amountToWithdraw); |
|
_withdrawAllSurcharges(); |
|
} |
|
|
|
|
|
|
|
|
|
function withdrawRamppSurcharges() public isRampp { |
|
require(ramppSurchargeBalance > 0, "WithdrawableV2: No Rampp surcharges in balance."); |
|
_withdrawAllSurcharges(); |
|
} |
|
|
|
|
|
|
|
|
|
function addSurcharge() internal { |
|
ramppSurchargeBalance += ramppSurchargeFee; |
|
} |
|
|
|
|
|
|
|
|
|
function hasSurcharge() internal returns(bool) { |
|
return msg.value == ramppSurchargeFee; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setRamppSurcharge(uint256 _newSurcharge) public isRampp { |
|
ramppSurchargeFee = _newSurcharge; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isApprovedForERC20Payments(address _erc20TokenContract) public view returns(bool) { |
|
return allowedTokenContracts[_erc20TokenContract].isActive == true; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function chargeAmountForERC20(address _erc20TokenContract) public view returns(uint256) { |
|
require(isApprovedForERC20Payments(_erc20TokenContract), "This ERC-20 contract is not approved to make payments on this contract!"); |
|
return allowedTokenContracts[_erc20TokenContract].chargeAmount; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addOrUpdateERC20ContractAsPayment(address _erc20TokenContract, bool _isActive, uint256 _chargeAmountInTokens) public onlyTeamOrOwner { |
|
allowedTokenContracts[_erc20TokenContract].isActive = _isActive; |
|
allowedTokenContracts[_erc20TokenContract].chargeAmount = _chargeAmountInTokens; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
function enableERC20ContractAsPayment(address _erc20TokenContract) public onlyTeamOrOwner { |
|
allowedTokenContracts[_erc20TokenContract].isActive = true; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
function disableERC20ContractAsPayment(address _erc20TokenContract) public onlyTeamOrOwner { |
|
allowedTokenContracts[_erc20TokenContract].isActive = false; |
|
} |
|
|
|
|
|
|
|
|
|
function enableERC20OnlyMinting() public onlyTeamOrOwner { |
|
onlyERC20MintingMode = true; |
|
} |
|
|
|
|
|
|
|
|
|
function disableERC20OnlyMinting() public onlyTeamOrOwner { |
|
onlyERC20MintingMode = false; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setERC20PayableAddress(address _newErc20Payable) public onlyTeamOrOwner { |
|
require(_newErc20Payable != address(0), "WithdrawableV2: new ERC-20 payout cannot be the zero address"); |
|
require(_newErc20Payable != erc20Payable, "WithdrawableV2: new ERC-20 payout is same as current payout"); |
|
erc20Payable = _newErc20Payable; |
|
} |
|
|
|
|
|
|
|
|
|
function resetRamppSurchargeBalance() public isRampp { |
|
ramppSurchargeBalance = 0 ether; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setRamppAddress(address _newAddress) public isRampp { |
|
require(_newAddress != RAMPPADDRESS, "WithdrawableV2: New Rampp address must be different"); |
|
RAMPPADDRESS = _newAddress; |
|
payableAddresses[0] = _newAddress; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract contract EarlyMintIncentive is Teams, ERC721A { |
|
uint256 public PRICE = 1 ether; |
|
uint256 public EARLY_MINT_PRICE = 1 ether; |
|
uint256 public earlyMintTokenIdCap = 100; |
|
bool public usingEarlyMintIncentive = true; |
|
|
|
function enableEarlyMintIncentive() public onlyTeamOrOwner { |
|
usingEarlyMintIncentive = true; |
|
} |
|
|
|
function disableEarlyMintIncentive() public onlyTeamOrOwner { |
|
usingEarlyMintIncentive = false; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setEarlyMintTokenIdCap(uint256 _newTokenIdCap) public onlyTeamOrOwner { |
|
require(_newTokenIdCap <= collectionSize, "Cannot set incentive tokenId cap larger than totaly supply."); |
|
require(_newTokenIdCap >= 1, "Cannot set tokenId cap to less than the first token"); |
|
earlyMintTokenIdCap = _newTokenIdCap; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setEarlyIncentivePrice(uint256 _feeInWei) public onlyTeamOrOwner { |
|
EARLY_MINT_PRICE = _feeInWei; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setPrice(uint256 _feeInWei) public onlyTeamOrOwner { |
|
PRICE = _feeInWei; |
|
} |
|
|
|
function getPrice(uint256 _count) public view returns (uint256) { |
|
require(_count > 0, "Must be minting at least 1 token."); |
|
|
|
|
|
|
|
if( |
|
usingEarlyMintIncentive == false || |
|
currentTokenId() > earlyMintTokenIdCap |
|
) { |
|
return PRICE * _count; |
|
} |
|
|
|
uint256 endingTokenId = currentTokenId() + _count; |
|
|
|
|
|
if(endingTokenId <= earlyMintTokenIdCap) { |
|
return EARLY_MINT_PRICE * _count; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint256 incentiveTokenCount = earlyMintTokenIdCap - currentTokenId(); |
|
uint256 outsideIncentiveCount = endingTokenId - earlyMintTokenIdCap; |
|
|
|
return (EARLY_MINT_PRICE * incentiveTokenCount) + (PRICE * outsideIncentiveCount); |
|
} |
|
} |
|
|
|
|
|
|
|
abstract contract RamppERC721A is |
|
Ownable, |
|
Teams, |
|
ERC721A, |
|
WithdrawableV2, |
|
ReentrancyGuard |
|
, EarlyMintIncentive |
|
, Allowlist |
|
|
|
{ |
|
constructor( |
|
string memory tokenName, |
|
string memory tokenSymbol |
|
) ERC721A(tokenName, tokenSymbol, 1, 1000) { } |
|
uint8 public CONTRACT_VERSION = 2; |
|
string public _baseTokenURI = "ipfs://bafybeidp24m5lg4okzwawfb7ccydkspwuql3iv7e2njtxdawep2flwsm64/"; |
|
|
|
bool public mintingOpen = true; |
|
|
|
|
|
uint256 public MAX_WALLET_MINTS = 3; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mintToAdminV2(address _to, uint256 _qty) public onlyTeamOrOwner{ |
|
require(_qty > 0, "Must mint at least 1 token."); |
|
require(currentTokenId() + _qty <= collectionSize, "Cannot mint over supply cap of 1000"); |
|
_safeMint(_to, _qty, true); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mintTo(address _to) public payable { |
|
require(onlyERC20MintingMode == false, "Only minting with ERC-20 tokens is enabled."); |
|
require(getNextTokenId() <= collectionSize, "Cannot mint over supply cap of 1000"); |
|
require(mintingOpen == true && onlyAllowlistMode == false, "Public minting is not open right now!"); |
|
|
|
require(canMintAmount(_to, 1), "Wallet address is over the maximum allowed mints"); |
|
require(msg.value == getPrice(1), "Value needs to be exactly the mint fee!"); |
|
|
|
_safeMint(_to, 1, false); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mintToMultiple(address _to, uint256 _amount) public payable { |
|
require(onlyERC20MintingMode == false, "Only minting with ERC-20 tokens is enabled."); |
|
require(_amount >= 1, "Must mint at least 1 token"); |
|
require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction"); |
|
require(mintingOpen == true && onlyAllowlistMode == false, "Public minting is not open right now!"); |
|
|
|
require(canMintAmount(_to, _amount), "Wallet address is over the maximum allowed mints"); |
|
require(currentTokenId() + _amount <= collectionSize, "Cannot mint over supply cap of 1000"); |
|
require(msg.value == getPrice(_amount), "Value below required mint fee for amount"); |
|
|
|
_safeMint(_to, _amount, false); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mintToMultipleERC20(address _to, uint256 _amount, address _erc20TokenContract) public payable { |
|
require(_amount >= 1, "Must mint at least 1 token"); |
|
require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction"); |
|
require(getNextTokenId() <= collectionSize, "Cannot mint over supply cap of 1000"); |
|
require(mintingOpen == true && onlyAllowlistMode == false, "Public minting is not open right now!"); |
|
|
|
require(canMintAmount(_to, 1), "Wallet address is over the maximum allowed mints"); |
|
|
|
|
|
require(isApprovedForERC20Payments(_erc20TokenContract), "ERC-20 Token is not approved for minting!"); |
|
uint256 tokensQtyToTransfer = chargeAmountForERC20(_erc20TokenContract) * _amount; |
|
IERC20 payableToken = IERC20(_erc20TokenContract); |
|
|
|
require(payableToken.balanceOf(_to) >= tokensQtyToTransfer, "Buyer does not own enough of token to complete purchase"); |
|
require(payableToken.allowance(_to, address(this)) >= tokensQtyToTransfer, "Buyer did not approve enough of ERC-20 token to complete purchase"); |
|
require(hasSurcharge(), "Fee for ERC-20 payment not provided!"); |
|
|
|
bool transferComplete = payableToken.transferFrom(_to, address(this), tokensQtyToTransfer); |
|
require(transferComplete, "ERC-20 token was unable to be transferred"); |
|
|
|
_safeMint(_to, _amount, false); |
|
addSurcharge(); |
|
} |
|
|
|
function openMinting() public onlyTeamOrOwner { |
|
mintingOpen = true; |
|
} |
|
|
|
function stopMinting() public onlyTeamOrOwner { |
|
mintingOpen = false; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mintToAL(address _to, bytes32[] calldata _merkleProof) public payable { |
|
require(onlyERC20MintingMode == false, "Only minting with ERC-20 tokens is enabled."); |
|
require(onlyAllowlistMode == true && mintingOpen == true, "Allowlist minting is closed"); |
|
require(isAllowlisted(_to, _merkleProof), "Address is not in Allowlist!"); |
|
require(getNextTokenId() <= collectionSize, "Cannot mint over supply cap of 1000"); |
|
require(canMintAmount(_to, 1), "Wallet address is over the maximum allowed mints"); |
|
require(msg.value == getPrice(1), "Value needs to be exactly the mint fee!"); |
|
|
|
|
|
_safeMint(_to, 1, false); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mintToMultipleAL(address _to, uint256 _amount, bytes32[] calldata _merkleProof) public payable { |
|
require(onlyERC20MintingMode == false, "Only minting with ERC-20 tokens is enabled."); |
|
require(onlyAllowlistMode == true && mintingOpen == true, "Allowlist minting is closed"); |
|
require(isAllowlisted(_to, _merkleProof), "Address is not in Allowlist!"); |
|
require(_amount >= 1, "Must mint at least 1 token"); |
|
require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction"); |
|
|
|
require(canMintAmount(_to, _amount), "Wallet address is over the maximum allowed mints"); |
|
require(currentTokenId() + _amount <= collectionSize, "Cannot mint over supply cap of 1000"); |
|
require(msg.value == getPrice(_amount), "Value below required mint fee for amount"); |
|
|
|
|
|
_safeMint(_to, _amount, false); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mintToMultipleERC20AL(address _to, uint256 _amount, bytes32[] calldata _merkleProof, address _erc20TokenContract) public payable { |
|
require(onlyAllowlistMode == true && mintingOpen == true, "Allowlist minting is closed"); |
|
require(isAllowlisted(_to, _merkleProof), "Address is not in Allowlist!"); |
|
require(_amount >= 1, "Must mint at least 1 token"); |
|
require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction"); |
|
require(canMintAmount(_to, _amount), "Wallet address is over the maximum allowed mints"); |
|
require(currentTokenId() + _amount <= collectionSize, "Cannot mint over supply cap of 1000"); |
|
|
|
|
|
|
|
require(isApprovedForERC20Payments(_erc20TokenContract), "ERC-20 Token is not approved for minting!"); |
|
uint256 tokensQtyToTransfer = chargeAmountForERC20(_erc20TokenContract) * _amount; |
|
IERC20 payableToken = IERC20(_erc20TokenContract); |
|
|
|
require(payableToken.balanceOf(_to) >= tokensQtyToTransfer, "Buyer does not own enough of token to complete purchase"); |
|
require(payableToken.allowance(_to, address(this)) >= tokensQtyToTransfer, "Buyer did not approve enough of ERC-20 token to complete purchase"); |
|
require(hasSurcharge(), "Fee for ERC-20 payment not provided!"); |
|
|
|
bool transferComplete = payableToken.transferFrom(_to, address(this), tokensQtyToTransfer); |
|
require(transferComplete, "ERC-20 token was unable to be transferred"); |
|
|
|
_safeMint(_to, _amount, false); |
|
addSurcharge(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function openAllowlistMint() public onlyTeamOrOwner { |
|
enableAllowlistOnlyMode(); |
|
mintingOpen = true; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function closeAllowlistMint() public onlyTeamOrOwner { |
|
disableAllowlistOnlyMode(); |
|
mintingOpen = false; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function canMintAmount(address _address, uint256 _amount) public view returns(bool) { |
|
require(_amount >= 1, "Amount must be greater than or equal to 1"); |
|
return (_numberMinted(_address) + _amount) <= MAX_WALLET_MINTS; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setWalletMax(uint256 _newWalletMax) public onlyTeamOrOwner { |
|
require(_newWalletMax >= 1, "Max mints per wallet must be at least 1"); |
|
MAX_WALLET_MINTS = _newWalletMax; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setMaxMint(uint256 _newMaxMint) public onlyTeamOrOwner { |
|
require(_newMaxMint >= 1, "Max mint must be at least 1"); |
|
maxBatchSize = _newMaxMint; |
|
} |
|
|
|
|
|
|
|
|
|
function _baseURI() internal view virtual override returns(string memory) { |
|
return _baseTokenURI; |
|
} |
|
|
|
function baseTokenURI() public view returns(string memory) { |
|
return _baseTokenURI; |
|
} |
|
|
|
function setBaseURI(string calldata baseURI) external onlyTeamOrOwner { |
|
_baseTokenURI = baseURI; |
|
} |
|
|
|
function getOwnershipData(uint256 tokenId) external view returns(TokenOwnership memory) { |
|
return ownershipOf(tokenId); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
contract Bi123CommunityPassContract is RamppERC721A { |
|
constructor() RamppERC721A("Bi123CommunityPass", "BCP"){} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|