Skip to content

Commit

Permalink
Add transferFrom with signature
Browse files Browse the repository at this point in the history
  • Loading branch information
zZoMROT committed Jun 23, 2024
1 parent 8998b54 commit 102edf7
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 136 deletions.
15 changes: 14 additions & 1 deletion contracts/KycNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,25 @@ contract KycNFT is Ownable, ERC721 {
constructor(string memory name, string memory symbol, address owner) ERC721(name, symbol) Ownable(owner) {}

/**
* @notice See {transfer} method. This function overrides the ERC721 transferFrom function and can be called by the owner only.
* @notice Transfers a token to a specified address. Only the owner can call this function.
* @param to The address to transfer the token to.
* @param tokenId The ID of the token to be transferred.
*/
function transferFrom(address /* from */, address to, uint256 tokenId) public override onlyOwner() {
_transfer(to, tokenId);
}

/**
* @notice Transfers a token from account to another by token owner. This function using a valid owner's signature.
* @param from The address to transfer the token from.
* @param to The address to transfer the token to.
* @param tokenId The ID of the token to be transferred.
* @param signature The signature of the owner permitting the transfer.
*/
function transferFrom(address from, address to, uint256 tokenId, bytes calldata signature) public onlyOwnerSignature(tokenId, signature) {
super._transfer(from, to, tokenId);
}

function _transfer(address to, uint256 tokenId) internal {
if (_ownerOf(tokenId) == address(0)) revert ERC721NonexistentToken(tokenId);
_update(to, tokenId, address(0));
Expand Down
Loading

0 comments on commit 102edf7

Please sign in to comment.