The ERC721 sample in official doc is not working anymore

here’s the link

the compile result is

DeclarationError: Undeclared identifier. 
_setTokenURI(newItemId, tokenURI);

the compiler versions is

Truffle v5.3.0 (core: 5.3.0)
Node v12.18.2

my question is where sample code of ERC721 for version ^4.0.0 ?

openzeppelin broke up the contract to have the tokenURI stuff be its own extension (check out extensions here). So in order to get the token URI stuff, you’d need to inherit ERC721URIStorage instead of ERC721. (ERC721URIStorage inherits ERC721).


You can also use the Contracts Wizard