How to take the money from the bidder's wallet when the owner accept the bid

I am asking about the bidding system of nft like in the 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 ?

because i would like to do this in my project too .

in my project smart contract :

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(msg.value > nftDetails[_tokenId].highestBid, "Bid must be higher than current highest bid");

    if (nftDetails[_tokenId].highestBidder != address(0)) {



    // 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 onlyOwner {

    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;


    _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);


In my frontend :

const placeBid = async(contractAddress:any,price:any)=>{

  try {

    const provider = await new ethers.BrowserProvider((window as any).ethereum);

    await provider.send("eth_requestAccounts", []);

    const signers = await provider.getSigner();

    if (signers) {

      const contractInstance = new ethers.Contract(





      // How to send the request ???


  } catch (error) {




if any one Knows this please help.

1 Like

Hi @SaM1

The auction amount should be transferred to the contract wallet as soon as the bidder bids. So that when the owner accepts the bid you can make transactions through the contract.

1 Like

But in opensea the bid amount would not transferred to the contract wallet as soon as the bidder bids. Only the amount transfer after the owner accept the bid offer. You can check that in [](https://Opensea Test)

Do you have any transaction hash of the bid which you performed on opensea? That should give more details on it.


1 Like

This transactions has erc20 and erc721 transfers.

Is it related to the bid or buy?

1 Like

this is when owner accept the bid offer

1 Like

In this image the tokens are being transferred from the WETH contract 0x9C047d...5e3ddaE7.

So if you have transaction hash related to bidding you might find that the bidder has approved to transfer of WETH to WETH contract.

1 Like

check this repo I have implemented auction and bidding contracts make sure to read them carefully and modify for you usage they are not audited yet but can work for your learning then get them audited

Your code is vulnerbale make sure to use dos protection and nonreentereant

The scenario you are giving is possible by signing and braodcasting a raw transaction but for your use case it will be better to store eth or funds in contract