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

ERC721 safeMint should return the tokenId #212

Open
nkavian opened this issue Jan 5, 2023 · 4 comments
Open

ERC721 safeMint should return the tokenId #212

nkavian opened this issue Jan 5, 2023 · 4 comments
Labels
good first issue Good for newcomers

Comments

@nkavian
Copy link

nkavian commented Jan 5, 2023

When auto increment ids are enabled, shouldn't the method also then return tokenId? Otherwise how would you know what token was minted?

image

@ericglau ericglau added the good first issue Good for newcomers label Jan 9, 2023
@frangio
Copy link
Contributor

frangio commented Jan 9, 2023

Otherwise how would you know what token was minted?

Do you mean when you invoke this function off-chain? In that case you would use the Transfer event, and in fact the return value wouldn't be available.

Or do you have another scenario in mind?

@nkavian
Copy link
Author

nkavian commented Jan 9, 2023

The contract caller doesn't know the value of the new tokenId that was generated. I'm suggesting an implementation like this:

function safeMint(address to) public onlyOwner returns (uint256) {
    uint256 tokenId = _tokenIdCounter.current();
    _tokenIdCounter.increment();
    _safeMint(to, tokenId);
    return tokenId;
}

@EthixLucifer
Copy link

can i work on this issue @ericglau

@ericglau
Copy link
Member

@EthixLucifer Sure, thanks. You can find development setup steps in the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants