// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract IsotopicAsset is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; bool public paused; mapping(address => uint256) public whitelisted; mapping(address => uint256) public balance; event BaseURIChanged(string indexed _oldBaseURI, string indexed _newBaseURI); event BaseExtensionChanged(string indexed _oldBaseExtension, string indexed _newBaseExtension); event PausedChanged(bool indexed _oldPaused, bool indexed _newPaused); constructor( string memory _name, string memory _symbol, string memory _initBaseURI, bool _paused ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); paused = _paused; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function mint(address _to, uint256 _mintAmount) public { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); if (msg.sender != owner()) { require(whitelisted[msg.sender] >= _mintAmount, "only whitelist addresses can mint"); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } if (msg.sender != owner()){ whitelisted[msg.sender] -= _mintAmount; } balance[_to] += _mintAmount; } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, baseExtension)) : ""; } function setBaseURI(string memory _newBaseURI) public onlyOwner { string memory oldBaseURI = baseURI; baseURI = _newBaseURI; emit BaseURIChanged(oldBaseURI, _newBaseURI); } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { string memory oldBaseExtension = baseExtension; baseExtension = _newBaseExtension; emit BaseExtensionChanged(oldBaseExtension, _newBaseExtension); } function pause(bool _state) public onlyOwner { bool oldPaused = paused; paused = _state; emit PausedChanged(oldPaused, _state); } function setUserWhitelistAmount(address _user, uint256 _amount) public onlyOwner { whitelisted[_user] = _amount; } function increaseUserWhitelistAmount(address _user, uint256 _amount) public onlyOwner { whitelisted[_user] += _amount; } function getUserWhitelistAmount(address _user) public view returns (uint256){ return whitelisted[_user]; } function transferWhitelists(address _to, uint256 _amount) public { require(whitelisted[msg.sender] >= _amount, "Cannot transfer more whitelists than available."); whitelisted[_to] += _amount; whitelisted[msg.sender] -= _amount; } }