Skip to content

evandotdev/solidity-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

solidity-contracts

RandomWords ERC721 NFT Gas Comparison

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.

Screenshot from 2022-04-11 03-27-51

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors