Auction Data – How to Decide Between On-Chain and Off-Chain Storage for Auction Data

auctionserc-20erc-721nftsolidity

Currently I am trying to build a NFT marketplace and I am currently at a point where I need to make a design choice. In my current contract I have the data about the auction on chain. And every bid is recorded on chain as well.

As I realize that this will cost a lot of gas fees, I am thinking about moving the auction data off-chain (only the NFT and a flag that it is up for sale remains on chain). The rest of the auction data I would store in a separate backend. And for bidding I would just use the approve function from a ERC20 token for the bids and the same for the NFT. Looking at Opensea I think this is how they do it. Otherwise I could not imagine how they are able to do things like extending the auction by 15 minutes without big costs.
By doing it like this the bidder would only need to pay once for the approval but can then bid as often as they like (considering their balance).

Is it a good idea to do it like this or are big marketplaces doing it differently?

Best Answer

It appears you are very early in the design process and are still studying existing solutions. So I'll reply here with just some broad concepts. Good luck on your journey!

Fully off-chain

This is the approach OpenSea uses. Everybody with a token needs to approve or, more likely, approveForAll their tokens to the OpenSea marketplace contract.

Commitments are created by signing "messages". These are off-chain transactions. However, cancelling transactions requires posting on-chain.

The main criticism of this approach is that it is centralized--third parties cannot read the order book in a first-party way.

But the benefit is strong, this is almost the cheapest way to implement a marketplace.*

*A slightly cheaper way involves batching the "cancel" transactions and is technically an L-2 solution.

Fully on-chain

Here the order book is entirely on-chain for inspection and action. The market continues to work even if the Web2 website is offline.

I have studied CryptoPunks and most recently released the Area market contract that implements this. Please see: https://github.com/AreaWorld/ethereum-contracts

This is fully transparent and works entirely without a website.


There are more partially-on-chain solutions that mix the benefits of economy and decentralization. Building a marketplace requires careful implementation. I recently did a review of Number Board and found problems, you can see this publication for some hints https://privacylog.blogspot.com/2021/09/implementation-issues-make-number-board.html

Related Topic