Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transferFrom gas estimates for various situations #83

Closed
fulldecent opened this issue Feb 9, 2022 · 6 comments · Fixed by #319
Closed

Add transferFrom gas estimates for various situations #83

fulldecent opened this issue Feb 9, 2022 · 6 comments · Fixed by #319

Comments

@fulldecent
Copy link
Contributor

This is an important consideration of whether to use this implementation.

@fulldecent
Copy link
Contributor Author

Here's a start

https://twitter.com/fulldecent/status/1491506122565595141

Did this manually, we can make good tooling for this.

@Vectorized
Copy link
Collaborator

The more popular the project, the more gas ERC721A can save.

The gas savings during mint (high BASEFEE period) can be way more than
the extra overhead incurred when transferring tokens (low BASEFEE period).

A general rule-of-thumb to minimize gas is to transfer in ascending tokenId order.

Also, it has the indirect effect of discouraging dumping (promoting hodling), especially for those who mint large batches. ;)

@0xsudo-eth
Copy link

@fulldecent @Vectorized check this issue, if we good with the proposal I can do

@alephao
Copy link

alephao commented Apr 26, 2022

Hello, I made a benchmark that is more precise than the one showing here and compares gas usage with other implementations. It compares not only mint but also transferFrom on many cases and all other methods so the developers have a better picture of what the gas usage will be when using this or any other contract.

Feel free to grab the results or link the codebase, I think it's more trustworthy than the one showing on README since all comparisons are made using the same process, and by someone not involved in this project (so no bias in favor of this proj).

https://github.com/alephao/solidity-benchmarks
https://github.com/alephao/solidity-benchmarks/blob/main/ERC721.md

@caffeinum
Copy link
Contributor

I wonder how it scales in the future? Most of the benchmarks are only interested in 100 tokens; but when Ethereum NFT is the base for (m)etaverse, and we need collections of billions NFTs, some people owning millions of them, how many gas transfer will eat? Even if the block gas limit is raised to 100_000_000 gas, is it possible to being "locked out" of your tokens?

@Vectorized
Copy link
Collaborator

@caffeinum If you mint at the block gas limit (about 16K tokens for now on ETH), you won’t be able to directly transfer the last token in the batch. This is because the LOG4 opcode (1875 gas) emitted per mint costs less than a SLOAD opcode (2100 gas).

You can however, transfer a token in the middle of the batch to initialize it so that the token at the end can be transferred within the block gas limit.

In an upcoming PR #272, we will have a function to directly initialize a token without transferring it.

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 a pull request may close this issue.

5 participants