Skip to content

An attempt to improve gas usage of OpenZepplin's implementation of the ERC721-Enumerable extension

License

Notifications You must be signed in to change notification settings

Shazambom/ERC721-Enumerable-Shazam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introducing ERC721EnumerableS!

This is an experiment to see if I can optimize the ERC721 NFT Extension ERC721Enumerable.

When minting multiple NFTs this new version of the ERC721Enumerable extension reduces gas price by around 400%

However, this implementation does come with some caveats

  • This implemention abuses the view functions in the interface
  • This means the actual implemented functions may not nessesarily be more gas efficient than the OpenZeppelin implementation
  • In fact OpenZeppelin's functions only require O(1) to retreive their data in their contracts where as this implementation generally requires O(N) operations

So how is this implementation better?

In general these "read only" view functions aren't called within other contracts, they are called by DAPPs that use contracts as their API. As long as these interface functions aren't called outside of a view context in solidity they incur 0 gas fees. Therefore, we are getting the same functionality as ERC721Enumerable at 1/4th the mint cost.

Note

This is a work in progress, feedback is welcome!

Contribution guide

This repo uses foundry for its testing/dev environment, please submit all tests in solidity.

About

An attempt to improve gas usage of OpenZepplin's implementation of the ERC721-Enumerable extension

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages