nft.baseURI is not a function

Hi, I have a problem with await nft.baseURI(), Uncaught TypeError: nft.baseURI is not a function
at evalmachine.:1:13 and in https://rinkeby-api.opensea.io/ i have InvalidTokenUrlResponseException: Invalid response, please change your ‘Content-Type’ header from ‘text/html’ to ‘application/json’

1 Like

There is no more baseURI function. there is now _baseURI()

Check the functions out:

/**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    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()))
            : '';
    }

    /**
     * @dev Base URI for computing {tokenURI}. Empty by default, can be overriden
     * in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }
1 Like

Make sure that you have the proper baseURI function in your contract. The application that serve the metadata should return the proper header to let know OpenSea what is the format of your Data.

1 Like

Hi @sebofew811,

The guide was written for OpenZeppelin Contracts 3.x. You can skip calling nft.baseURI() for OpenZeppelin Contracts 4.x.

Can you share a screenshot of your error that you get with OpenSea?
https://rinkeby-api.opensea.io/asset/0x5c5c53D13aD8725cFE551D6E9dB93e9a9D38D78D/0/validate/