I'm making an nft marketplace and I want the buyers to buy the nfts with WETH.
function createMarketSale(address nftContract, uint256 itemId)
public
nonReentrant
{
require(
msg.sender != idToMarketItem[itemId].seller,
"you cannot buy this item, this is your's"
);
uint256 price = idToMarketItem[itemId].price;
uint256 tokenId = idToMarketItem[itemId].tokenId;
require(WETH.balanceOf(msg.sender) >= price, "Insufficient funds");
WETH.transferFrom(
msg.sender,
idToMarketItem[itemId].seller,
price
);
IERC721(nftContract).transferFrom(address(this), msg.sender, tokenId);
}
Is this supposed to work?