I have some ERC721 NFTs in my wallet minted in A smart contract.
I want to transfer that NFTs to another wallet using my smart contract.
But I am getting error like: "ERC721: approve caller is not owner nor approved for all"
This is my code:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Coller is ERC721Enumerable, Ownable {
address public deadAddress = 0x000000000000000000000000000000000000dEaD;
constructor(
) ERC721("Coller Token", "Coller") {
}
function approveAndTransfer(ERC721 nft, uint256 _tokenId) public {
nft.approve(deadAddress, _tokenId);
nft.transferFrom(msg.sender, deadAddress,_tokenId);
}
}
Who can fix this error and help me?