Refactoring function ownerOf in ERC721.sol
See original GitHub issueCheck the presence of a token using the function _exists. Now the ownerOf function corresponds to the getApproved function.
function ownerOf(uint256 tokenId) public view returns (address) {
require(_exists(tokenId));
return _tokenOwner[tokenId];
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Can ChatGPT really be trusted to write a smart contract or to ...
Developers are beginning to explore the potential of asking ChatGPT to assist with writing, reviewing or refactoring code, as well as providing ...
Read more >How to send ether to erc721 token owner? - Stack Overflow
ownerOf returns address, so I set payable address inside of sendEther function. However, error says 'Type address is not implicitly convertible ...
Read more >ERC721.sol - aaron bloomfield @ github.io
function ownerOf (uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: ...
Read more >Address 0x6261d8e873b9a7be666d0aa07357bc9d6bcc7feb
File 1 of 14 : Marketplace.sol ... File 2 of 14 : ERC721.sol ... function ownerOf(uint256 tokenId) public view virtual override returns ......
Read more >Ethereum Contract Diff Checker - Etherscan
_ */ function functionCall(address target, bytes memory data) internal returns ... Strings.sol"; /** * @title ERC721 Non-Fungible Token Standard basic ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ahh, I see. For reference for everyone else, these are the functions being discussed:
Yes, I did think of that when revising
ownerOf
recently, but unfortunately due to how Solidity’s codegen works, that would mean performing an extraSLOAD
(since_exists
doesn’t return the owner). I thinkownerOf
is short and readable enough that the benefit of performing that deduplication may not be warranted. @frangio thoughts on this?I agree with @nventuro that the code is short enough that we should prioritize the cheaper implementation.