Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
rayliao1031 committed Mar 13, 2024
1 parent a925c31 commit b5d1e24
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion hw1/src/NFinTech/NFinTech.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,19 @@ contract NFinTech is IERC721 {
}

function safeTransferFrom(address from, address to, uint256 tokenId) public {
safeTransferFrom(from, to, tokenId, "");
require(_owner[tokenId] == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
require(msg.sender == from || getApproved(tokenId) == msg.sender || isApprovedForAll(from, msg.sender), "ERC721: transfer caller is not owner nor approved");

// 执行转移操作
_balances[from] -= 1;
_balances[to] += 1;
_owner[tokenId] = to;

// 清除之前的授权
_tokenApproval[tokenId] = address(0);

emit Transfer(from, to, tokenId);
}

}

0 comments on commit b5d1e24

Please sign in to comment.