0

I am asking about the bidding system of nft in opensea. When the user participate in a bidding , the user enter a bid amount but the amount would not transfer at that time. The money will transfer from the bidder when the owner of the NFT accept the bid offer. When the owner accept the bid offer the money in the bidder's wallet will transfer automatically without any notification. I want to know How is this works ?

if any one Knows this please help.

function placeBid(uint256 _tokenId,uint256 _bidPrice) public {
    require(nftDetails[_tokenId].inAuction, "Auction not in progress");
    require(_bidPrice > nftDetails[_tokenId].basePrice,"Bid price is lower than base price");
    require(_bidPrice > nftDetails[_tokenId].highestBid, "Bid must be higher than current highest bid");

    if (nftDetails[_tokenId].highestBidder != address(0)) {
        payable(nftDetails[_tokenId].highestBidder).transfer(nftDetails[_tokenId].highestBid);
    }

    // Update highest bid and bidder
    nftDetails[_tokenId].highestBid = msg.value;
    nftDetails[_tokenId].highestBidder = msg.sender;

    emit placedBid(msg.sender, _tokenId, block.timestamp, _bidPrice);
}


function endAuction(uint256 _tokenId) public {
    address owner = ownerOf(_tokenId);
    require(nftDetails[_tokenId].inAuction, "Auction not in progress");
    require(block.timestamp >= nftDetails[_tokenId].auctionEndTime, "Auction has not ended yet");

    address seller = ownerOf(_tokenId);
    address highestBidder = nftDetails[_tokenId].highestBidder;
    uint256 winningBid = nftDetails[_tokenId].highestBid;
    cryptoBatStorageInstance.updateNftDetailsOwner(msg.sender,address(this),owner,_tokenId,nftDetails[_tokenId].creator);
    _transfer(seller, highestBidder, _tokenId);

    // Reset auction details
    nftDetails[_tokenId].inAuction = false;
    nftDetails[_tokenId].auctionEndTime = 0;
    nftDetails[_tokenId].basePrice = 0;
    emit auctionEnded(seller, highestBidder, _tokenId, block.timestamp, winningBid);
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.