6

openzeppelin中ERC721.sol的bug

 2 years ago
source link: https://learnblockchain.cn/question/2428
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
openzeppelin中ERC721.sol的bug | 登链社区 | 技术问答

openzeppelin中ERC721.sol的bug

erc721中对 safeTransferFrom函数实现的中,_safeTransfer 函数中先调用了_transfer,再去校验 toAddress是否能接收erc721,这个顺序是反了吧,应该先校验,再transfer才对呀?

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol

Tiny熊 - 布道者 16小时前

  擅长:智能合约,以太坊

这里要调用 onERC721Received, 当然是在 transfer 之后调用。

function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); }

看上面的代码,先执行了transfer,都 转帐完成了,然后才去做校验,我觉得先后顺序错了呢


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK