I’m trying to implement an NFT Auction and I followed the tutorial on the moralis channel that showed to implement them the following way:
Each time someone outbids another person, the previous bidder’s bid gets put into a pendingReturns array, where that bidder then needs to manually withdraw their money to get it back.
When the auction time is up, people can no longer place bids, but the auction doesn’t officially end (as in the winner gets the NFT and the NFT owner gets the money) until the auctionEnd function is called.
Making a user manually withdraw their money after they get outbid is obviously not the ideal way to do things from a UX perspective, along with making the owner manually end the auction before the NFT can be transferred.
Is it a bad idea to automate this return of funds to the previous bidder right when they get outbid instead of adding it to the pendingReturns mapping for them to take out later? Is there a better way or better place in the contract to do this? If I were to put it at the end of the auction and there were like 10 previous bidders, would the gas costs for calling the end function be enormous?
Also is there a way to automate the ending of the auction so that as soon as the time is up, the transfer of NFT ownership takes place, the auction owner gets paid etc. without needing someone to manually call the end auction method?