Hey guys, I am facing an error which is
transact to LotteryEscrowParent.callPurchaseItem errored: VM error: revert.
revert
The transaction has been reverted to the initial state.
Note: The called function should be payable if you send value and the value you send should be less than your current balance.
In the following function:-
function callPurchaseItem(
uint256 tokenId,
address tokenAddress,
address collectionContract,
uint256 price
)public{
LotteryEscrow(tokenAddress).purchaseItem(tokenId,payable(msg.sender),collectionContract, price);
}
function purchaseItem(uint256 tokenId, address payable to, address collectionContract, uint256 price) external {
//uint256 _totalPrice = getTotalPrice(tokenId);
MarketItem memory item = marketItems[tokenId];
require(!item.sold, "item already sold");
payable(item.seller).transfer(price);
item.sold = true;
IERC721(item.nftContract).transferFrom(item.seller, to, tokenId);
marketItems[tokenId].owner = payable(to);
soldItems[collectionContract].push(tokenId);
emit Bought(address(this), item.tokenId, price, item.seller, to);
}
Any help! Thank you:)