I am using the IERC721.transferFrom() openZeppelin interface. When I try to transfer the NFT from msg.sender(me) to the contract (address.(this)) I get a Fail with error 'ERC721: transfer caller is not owner nor approved'
error. I am trying to list an NFT to my marketplace without having to do multiple transactions. What am I missing?
contract Market is OwnableUpgradeable, ReentrancyGuardUpgradeable {
function _createListing(
address nftAddress,
uint256 tokenId,
address _listingTokenAddress,
string calldata _listingTokenName,
string calldata _listingTokenSymbol,
uint256 price,
uint256 expiration
) internal {
require(nftAddress != address(0), "zero address");
require(price > 0, "zero amount");
IERC721Upgradeable(nftAddress).transferFrom( //<-- Issue line
msg.sender,
address(this),
tokenId
);
PropertyListing memory _propertyListing = PropertyListing(
nftAddress,
tokenId,
price,
_listingTokenAddress,
_listingTokenName,
_listingTokenSymbol,
msg.sender,
expiration,
true,
false
);
listings.push(_propertyListing);
uint256 _id = listings.length - 1;
emit NewPropertyListing(
_id,
nftAddress,
tokenId,
price,
_listingTokenAddress,
_listingTokenName,
_listingTokenSymbol,
msg.sender,
expiration,
true,
false
);
}
}