chiru-labs / ERC721A

https://ERC721A.org
MIT License
2.51k stars 842 forks source link

Non-sequential minting (a.k.a spot-minting) support #479

Closed Vectorized closed 9 months ago

Vectorized commented 10 months ago

This PR gives ERC721A the ability to mint tokens in non-sequential order.

Devs will need to override a new _sequentialUpTo() function to return a value less than 2**256 - 1 to activate this feature.

About:

Zero-cost abstraction:

Notes:

Todo:

mvillere commented 9 months ago

Clever approach to implement this I think. I went through all the changes and didn't see any red flags. The only obvious thing that popped into my head is whether it makes sense to package spot + sequential mint functionality together in a single contract as I don't think a lot of mints will need both together. That being said, I do like having the capability now, and it added a lot less code to the base contract than I expected. Nicely done.

Vectorized commented 9 months ago

@mvillere Thanks so much for your review.

One possible use case is multi-chain NFTs. L1 minting can be sequential, while NFTs bridged from L2 -> L1 are spot minted.

Vectorized commented 9 months ago

Was initially thinking of a subclass that wraps the ERC721A's functions.

Decided on the current approach after hard marinating over a week:

dcapitator commented 9 months ago

Could we consider implementing batch spot minting as a highly anticipated use case?

Nice work.

lak02 commented 9 months ago

could be less fee for NFTs redeem

Nlferu commented 3 weeks ago

@Vectorized

I did not want to create new issue for this as I assume answer is clear, but I want to make sure by checking with you.

As you mentioned I use _mintSpot for cross-chain NFT's and I also use batchTransfer, batchBurn etc. but I assume that using _mintSpot disables batchTransfer and batchBurn by following condition: _currentIndex <= tokenId and there is no way to make those work without sequential mint am I right?

To give you some view of my project architecture I use batchMint, batchTransfer and batchBurn (all sequential) for my SourceNFT (blockchain A) and I use _mintSpot for DestinationNFT (blockchain B), so for blockchain B to transfer more tokens It is only possible to just call standard safeTransferFrom for each token right?

There is also one more thing as your docs says _sequentialUpTo() needs to return greater value than _startTokenId(), so I made my sourceNFT _startTokenId = 2 and then on destination my _sequentialUpTo = 1, so user is able to transfer even 1st token. But is it possible to somehow turn on _mintSpot feature from index 0? So we keep minting sequentially from 0 on chain A and then we can use _mintSpot for tokenId = 0? I believe it is not possible to do so...

Thanks in advance for any confirmations/explanation if I'm right or there is a way to solve those problems somehow