I was following a tutorial to make a basic NFT, but I wanted to make an upgradeable NFT with ERC721Upgradeable.sol (is this even useful?). In the tutorial @ https://docs.alchemy.com/alchemy/tutorials/how-to-create-an-nft, they use the method _setTokenURI(newItemId, tokenURI). However, that method does not appear to exist for ERC721Upgradeable.sol. Am I doing something wrong or is there a reason for this? My code is below.
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
contract MyNFT is ERC721Upgradeable, OwnableUpgradeable {
using CountersUpgradeable for CountersUpgradeable.Counter;
CountersUpgradeable.Counter private _tokenIds;
function initialize() public initializer {
__ERC721_init("MYNFT", "NFT");
}
function mintNFT(address recipient, string memory tokenURI)
public
onlyOwner
returns (uint256)
{
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(recipient, newItemId);
_setTokenURI(newItemId, tokenURI);
return newItemId;
}
}