-
Notifications
You must be signed in to change notification settings - Fork 842
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
Question/Change Request: Init currentIndex
with 1 instead of 0
#45
Comments
Yup this is on the roadmap. Feel free to open a PR if you have one ready! |
👍 Started working on a PR. |
Will leave the PR link here as a reference. It's not finished yet. Had only limited time today. |
PR is ready for review. ✌️ |
Quick question about this, if this PR gets approved, the default behaviour would be for the index to start at 1 right? |
Wow great work @Pczek , I will do some tests with this to use on one of my projects! Collections starting with 1 are a lot less confusing |
Yes. Having token id |
Looking to implement this in a project and had a few questions: Does function tokenByIndex(uint256 index) need to be adjusted? Token at index 0 is now tokenId 1. Also ownershipOf checks all the way down to zero, should change to
|
@jpegdigital yes you are right. I've adapted it in my PR. Fixing this, i've stumbled over the https://github.com/chiru-labs/ERC721A/blob/main/contracts/ERC721A.sol#L85-L108 |
Fixed the |
After some rework #66 is again ready for a second review before merging it. |
Since the Hashlips library which has a large following and is used by many beginners to help programatically generate artwork begins indexing at 1, we followed the OPs suggestion and begin indexing at 1 as well. uint256 internal _currentIndex = 1; It seems to work fine for us but that may be because we removed ERC721Enumerable from ERC721A and so we don't encounter any issues with the aforementioned Because of the fact that the function _totalSupply() internal view returns (uint256) {
unchecked {
return _currentIndex - 1;
}
} Please let me know if there's any problems with these modifications. Our contract implements a previous version of ERC721A that did not include the burn functionality which is why you don't see I'll be updating our contract that implements ERC721A to the recent changes made over the past 2 weeks but we already deployed a contract with the above modifications in production and just want to make sure there's no serious problem. |
@kyokosdream Which specific released version did you use to modify with your code? One thing which comes to mind, which could cause problems is the internally used |
I'm going to integrate the latest changes to the repo (re-entrant safe mint and start at index 1) regardless of whether it's merged or not since we need to put this into production ASAP. We've edited our contract to use the latest version of ERC721A as of today. The only changes it makes to ERC721A is that we include a @Vectorized Should I open a pull request for projects.md or request one of the maintainers to add our contract to the projects.md? To be honest, I've been the only technical member of my company's founding team so I am used to using git alone and not sure of proper protocol for pull requests etc. |
@kyokosdream Open a PR for |
This has now been addressed in #66 |
We've been using ERC721A in our latest NFT drop. It worked great, however, having the token indexes start 0 caused some edgecases in our other contracts for the token with the id 0.
For example we have a simple staking contract were we map the owner address to their staked token. Each address can only stake a single token so its a
mapping(address => uint256) ownerToToken
. However, each address of the map get's initialized with0
by solidity afaik. So doing stuff likerequire(ownerToToken[msg.sender] == 0, "Already staked a token");
does not work properly when supporting the token id 0 in the ERC721A contract.The text was updated successfully, but these errors were encountered: