RandomWords ERC721 NFT Gas Comparison
For this comparison I wanted to why some ( tweet 1, tweet 2 ) have been overriding ERC721's tokenURI function to view a token's metadata instead of using setTokenUri (from OpenZeppelin's ERC721UriStorage.sol) which I had been instructed to use in a tutorial. Turns out setTokenUri stores the whole Base64 encoded string for a token's metadata through a mapping(uint256 => string) which is an extremely expensive operation as seen below. It's much cheaper in gas fees to store integers representing indices in property arrays, store probably a bunch of uint8 or uint16 numbers in storage and override the tokenURI view function to view token metadata without costing gas.
