ERC721Consecutive - Change tokenId

Is it possible to change the tokenId to begin at 1 instead of 0 when using ERC721Consecutive?

1 Like

ERC721Consecutive uses the _mintConsecutive function that automatically uses 0 as the first tokenId, but that it because to get the first token Id it calls this function:

    function _totalConsecutiveSupply() private view returns (uint96) {
        (bool exists, uint96 latestId, ) = _sequentialOwnership.latestCheckpoint();
        return exists ? latestId + 1 : 0;
    }

As you can see in the return statement, if there wasnt a checkpoint, meaning if this will be the first token minted, it defaults to 0. If this function were virtual you could override it to default to 1, but since it is not, the way to do it is overriding the _mintConsecutive function to start at 1 instead.

2 Likes

I gave it a try, and it worked. Thank you!

1 Like

Merhaba sizden bir konuda destek almak için nasıl iletişime geçebilirim

Since version 5.0 of the contracts (oct 2023), there is now a function function _firstConsecutiveId() internal view virtual returns (uint96). The default value is 0, but it can be overriden to start at 1 or any other number.