Skip to content

Commit

Permalink
Final solved issue iiitl#3
Browse files Browse the repository at this point in the history
  • Loading branch information
Dishant-garg committed Mar 16, 2024
1 parent fd17b99 commit 9e64e07
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions contracts/Contract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ contract Contract {
receive() external payable {}


function bought(uint256 _nftID,uint256 _tokenID) public onlyBuyer(_nftID) {
require(msg.value == purchasePrice[_nftID]);
(bool success, ) = (seller).call{value: address(this).balance}("");
isListed[_nftID] = false;
IERC721(nftaddress).transferFrom(address(this), buyer[_nftID], _tokenID);
}
function bought(uint256 _nftID, uint256 _tokenID) public payable onlyBuyer(_nftID) {
require(msg.value == purchasePrice[_nftID], "Incorrect purchase price");

address payable userAddress = payable(address(this));
userAddress.transfer(msg.value);
(bool success, ) = seller.call{value: msg.value}("");
require(success, "Payment failed");
isListed[_nftID] = false;
IERC721(nftaddress).transferFrom(address(this), buyer[_nftID], _tokenID);
}


function getBalance() public view returns(uint256) {
Expand Down

0 comments on commit 9e64e07

Please sign in to comment.