Skip to content

Conversation

@mliu
Copy link

@mliu mliu commented Apr 4, 2023

This pull request aims to cut gas costs on the ERC20TransferableReceivable contract. The changes proposed are based on the findings of a gas profiler and include the following optimizations:

  • Remove the ERC721Enumerable functionality since it is not critical to the final product. Request Finance already knows all of a user's invoices and can map each one to their respective receivables. Previously we only used this to power our demo experience on the Huma dApp.
  • Stop using ERC721URIStorage as a glorified storage field for requestID. This is a significant waste of gas since strings need to be processed and stored. Instead, revert to the base ERC721 URI storage and create a new field requestID in the ReceivableInfo struct.

Using hardhat-gas-reporter, I measured a decrease in mint call costs from 320k to 177k. These changes cut gas costs per mint by almost half, resulting in savings of approximately $8-10 per mint on mainnet with current gas prices.


Before

Screen Shot 2023-04-04 at 1 10 10 PM

After

Screen Shot 2023-04-04 at 2 35 16 PM

@height
Copy link

height bot commented Apr 4, 2023

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants