Getting unexpected error while writing test for smart contract #2130
-
Hey guys I am writing tests for a NFT Markeplace smart contract, I have two contracts one for Marketplace and one for a basic ERC721 NFT. So while I am writing test I have a listNFT function in the Marketplace contract, now the problem is that the List Nft function checks for approval of token that is the token is approved for listing or not, while calling the function I am already calling the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Have you tried using a custom-error instead? As so: if (nft.getApproved(tokenId) != address(this)) {
revert NotApprovedForMarketplace();
} Do not forget to add the error NotApprovedForMarketplace(); |
Beta Was this translation helpful? Give feedback.
-
Hey got the problem the problem was in the |
Beta Was this translation helpful? Give feedback.
Hey got the problem the problem was in the
listNFT
function where I am checking for approving the nft address and not the marketplace address.