An error displaying an un-minted nft token

I wrote a contract, everything works, but when I enter a token number that is NOT MINT YET, I get the following error, as shown on the screen:

Error in etherscan

After minting it can be read without problems. Please tell me where the mistake was made?!

// File: contracts/Test.sol





 
contract Test is ERC721A, Ownable, ReentrancyGuard {
  using Strings for uint256;
 
  string public _baseTokenURI;
  string public hiddenMetadataUri;
  string public uriSuffix = '.json';

 
  uint256 public cost = 0.001 ether;
  uint256 public maxSupply = 400;
  uint256 public freeSupply = 200;
  uint256 public maxMintAmountPerTx = 5;
     
 
  bool public paused;
  bool public revealed = true;
  bool private parametersUpdated = false;
 
  constructor(
    string memory _hiddenMetadataUri
  ) ERC721A("Test", "Ts") {
 
    setHiddenMetadataUri(_hiddenMetadataUri);
  }
 
  function mint(uint256 _mintAmount) public payable nonReentrant {
    require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!");
    require(totalSupply() + _mintAmount <= maxSupply, "Max supply exceeded!");
    require(!paused, "The contract is paused!");
    require(msg.value >= cost * _mintAmount, "Insufficient funds!");
 
    if (totalSupply() >= freeSupply) {
      require(msg.value > 0, "Max free supply exceeded!");
    }

    _safeMint(_msgSender(), _mintAmount);

    if (totalSupply() >= freeSupply - 10 && !parametersUpdated) {
      updateParameters();
    }

  }

  function updateParameters() internal {
    cost = 0.001 ether;
    maxMintAmountPerTx = 100;
    parametersUpdated = true;
  }

  function setParametersUpdated(bool _parametersUpdated) public onlyOwner {
    parametersUpdated = _parametersUpdated;
  }

  function setParameters(uint256 _cost, uint256 _maxMintAmountPerTx, bool _parametersUpdated) public onlyOwner {
    cost = _cost;
    maxMintAmountPerTx = _maxMintAmountPerTx;
    parametersUpdated = _parametersUpdated;
  }
 
  function mintForAddress(uint256 _mintAmount, address _receiver) public onlyOwner {
    _safeMint(_receiver, _mintAmount);
  }
 
  function _startTokenId() internal view virtual override returns (uint256) {
    return 1;
  }
 
  function setRevealed(bool _state) public onlyOwner {
    revealed = _state;
  }
 
  function setCost(uint256 _cost) public onlyOwner {
    cost = _cost;
  }
 
  function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {
    maxMintAmountPerTx = _maxMintAmountPerTx;
  }
 
  function setMaxSupply(uint256 _maxSupply) public onlyOwner {
    maxSupply = _maxSupply;
  }

  function setFreeSupply(uint256 _freeSupply) public onlyOwner {
    freeSupply = _freeSupply;
  }

  function setPaused(bool _state) public onlyOwner {
    paused = _state;
  }
 
  function withdraw() public onlyOwner nonReentrant {
    (bool os, ) = payable(owner()).call{value: address(this).balance}('');
    require(os);
  }
 
  // METADATA HANDLING
 
  function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
    hiddenMetadataUri = _hiddenMetadataUri;
  }
 
  function setBaseURI(string calldata baseURI) public onlyOwner {
    _baseTokenURI = baseURI;
  }
 
  function _baseURI() internal view virtual override returns (string memory) {
      return _baseTokenURI;
  }
 
  function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
      require(_exists(_tokenId), "URI does not exist!");
 
      if (revealed) {
          return string(abi.encodePacked(_baseURI(), Strings.toString(_tokenId), uriSuffix));
      } else {
          return hiddenMetadataUri;
      }
  }
}

Ответы (0 шт):