1

If I want to implement a little NFT marketplace and want users to be able to put items up for sale, and other users to buy those, how should I do that? Do I need to make market contract that gets approved everytime someone puts up something for sale, and when someone buys that items the contract will execute the safeTransferFrom function?

0

Yes, this is one way people typically do it.

Better options are available if your marketplace only applies to one specific token.

6
  • Is this the best way to do it when I'm not working with only one specific token? – warren1235 May 12 at 19:04
  • Yes. Everybody is using setApprovalForAll. I don't know anybody using the single approve for this purpose. – William Entriken May 12 at 19:28
  • Can you elaborate on that? I know those functions, I just don't understand what you mean by this – warren1235 May 12 at 19:32
  • Using approve requires n operations to transfer n different tokens. But using setApprovalForAll requires 1 operation to transfer n different tokens. – William Entriken May 12 at 19:34
  • But a user only can put up for sale one nft at a time, so why does the market contract need setApprovalForAll? – warren1235 May 12 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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