I ran in to Solidity problem Need some help

I was Trying it for 3days to fixed it
it’s Hashlips contracts/NFT/NFT_FULL.sol
The Problem it was I put in https://remix.ethereum.org He show an erro in (using Strings for uint256;) Strings
and I fixed it (import “@openzeppelin/contracts/utils/Strings.sol”:wink: it’s become ok but He show onther erro
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
“ERC721Metadata: URI query for nonexistent token”
);

_exists(tokenId), exists it;s The erro

Please I need some Help

[quote=“shihab dollartreecompass, post:1, topic:25441, full:true”]
I was Trying it for 3days to fixed it
it’s Hashlips contracts/NFT/NFT_FULL.sol
The Problem it was I put in https:// remix . ethereum. org He show an erro in (using Strings for uint256;) Strings
and I fixed it (import “@openzeppelin/contracts/utils/Strings.sol”:wink: it’s become ok but He show onther erro
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
“ERC721Metadata: URI query for nonexistent token”
);

_exists(tokenId), exists it;s The erro

Please I need some Help
[/quote]

Hello, @shihab

To address this error, ensure that the _exists(tokenId) function call within the tokenURI function is correctly checking for the existence of the token with the given tokenId. The _exists function should return true if the token exists and false otherwise.

function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(_exists(tokenId), “ERC721Metadata: URI query for nonexistent token”);

string memory baseURI = _baseURI();
return bytes(baseURI).length > 0
    ? string(abi.encodePacked(baseURI, tokenId.toString()))
    : "";

}

Ensure that _exists function is correctly implemented and returns true when the token exists. If you’re using a standard ERC721 contract, this function should already be provided by the OpenZeppelin library or by your contract implementation.

I hope my suggestion is helpful to you.

Best Regard,
angela683

1 Like