1

I saw the contract as getApproved and ownerOf functions. What is the difference between owning the token under ERC721 and having approval? When the tokenid is transferred does that transfer ownership or approval?

/**
 * @dev Gets the approved address for a token ID, or zero if no address set
 * Reverts if the token ID does not exist.
 * @param tokenId uint256 ID of the token to query the approval of
 * @return address currently approved for the given token ID
 */
function getApproved(uint256 tokenId) public view returns (address) {
    require(_exists(tokenId));
    return _tokenApprovals[tokenId];
}

/**
 * @dev Gets the owner of the specified token ID
 * @param tokenId uint256 ID of the token to query the owner of
 * @return address currently marked as the owner of the given token ID
 */
function ownerOf(uint256 tokenId) public view returns (address) {
    address owner = _tokenOwner[tokenId];
    require(owner != address(0));
    return owner;
}
1

I think the answer is that an approved account can transfer on behalf of the owner.

/**
 * @dev Sets or unsets the approval of a given operator
 * An operator is allowed to transfer all tokens of the sender on their behalf
 * @param to operator address to set the approval
 * @param approved representing the status of the approval to be set
 */
function setApprovalForAll(address to, bool approved) public {
    require(to != msg.sender);
    _operatorApprovals[msg.sender][to] = approved;
    emit ApprovalForAll(msg.sender, to, approved);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.