question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ERC721 _safeMint and _safeTransferFrom

See original GitHub issue

ERC721 has safeTransferFrom that forces a receiver contract to implement the onERC721Received function. Just like our other ERC implementations, we should have an internal _safeTransferFrom that does the same thing without requiring anything of msg.sender. Note that we already have an internal _transferFrom.

Similarly, we should add _safeMint as an alternative to _mint, with the addition that it also call onERC721Received on a contract receiver.


Original issue:

ERC721 transfers are required to call onERC721Received if the receiver is a contract. I don’t know if this is specified in the EIP, but we might have to do the same in _mint. Currently we are not.

This needs some discussion because it would be a breaking change. Additionally, it may not be obvious that _mint will call an external contract, and as always this opens up the possibility for reentrancy.

Thanks @alcuadrado for pointing this out.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
alanarvelocommented, Jun 20, 2019

Hi guys @nventuro @balajipachai I think I understood what is required to fix this issue. What is the state of things? May I move forward?

0reactions
frangiocommented, Aug 15, 2019

Yes thanks for pointing it out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERC 721 - OpenZeppelin Docs
safeTransferFrom (address from, address to, uint256 tokenId) public. Transfers a specific NFT ( tokenId ) from one account ( from ) to another...
Read more >
erc 721 - What is the difference between safeTransferFrom ...
The safeTransferFrom function is used to check if the address receiving the token is an ERC-721 receiver or not. The goal is to...
Read more >
Tutorial: mint and transfer your own ERC-721(NFT) tokens
Step 2 Transfer the ERC-721 Token ... The safeTransferFrom function transfers tokenId token from from to to . Enter the owner's address in...
Read more >
Jumping into Solidity — The ERC721 Standard (Part 4)
The safeTransferFrom functions are almost identical to transferFrom except that they check whether the recipient is a valid ERC721 receiver contract, and if...
Read more >
ERC721.sol - aaron bloomfield @ github.io
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for ... function safeTransferFrom( address from, address to, uint256 tokenId ) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found