2

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?

2
  • It wouldn't be so expensive to store the previous bids in an array. You can do it on the chain.
    – trizin
    Sep 29, 2021 at 15:12
  • The problem would be more that each time a bid is made the bidder needs to pay gas fees. That is quite expansive for the user.
    – zanzoken
    Sep 30, 2021 at 7:33

1 Answer 1

3

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

2
  • 1
    Thank you William for your reply! Just a couple of questions. Opensea claims they can only deduct the amount that was bid for by the user. But the user needs to give Opensea an unlimited approval for their WETH token. Are they lying? Because for me it looks like they can transfer any amount they want. Or what does the signing of the "messages" actually do? I like the benefits of being on-chain obviously but it seems the downside of the gas fees for each bid is too high. Is there any other option to mitigate this issue? I guess a L2 solution?
    – zanzoken
    Oct 4, 2021 at 20:22
  • Yes, OpenSea requests an unnecessarily high allowance. A signed message confirms the consent a party to do a deal without that party needing to commit a transaction on-chain. There are plenty more options, including options that reduce gas cost. But you'll need a good study of your requirements to pick the right approach. Oct 6, 2021 at 0:39

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.