0

I'm developing a simple NFT marketplace where people can connect their own collections (each one having its own smart contract) and put those collection's NFTs for sale.

I saw a tutorial where the NFTs never leave the owner's hands when being listed for sale, and when the selling is done, the transfer happens between seller and buyer directly. Of course the seller has to approve the marketplace as an operator beforehand.

However, I saw another tutorial where the seller transfer the NFT to the marketplace at the moment of listing, and then when another person buys the NFT, the marketplace transfers it to the buyer. This requires no "approval" of the marketplace from the seller I suppose.

What are the pros and cons of each approach? Which is the more common one?

2 Answers 2

0

Your first tutorial is a simple example of nft. Nothing related to a marketplace.

A marketplace is any location, whether in person or online, that facilitates the exchange of goods between buyers and sellers.

If you are creating a marketplace, your Nft item should have a property to be listed on the marketplace.

struct NftItem{
    uint tokenId;
    uint price;
    // creator and owner are not same. creator someone who minted. creator does not change
    address creator;
    bool isListed;
  }

When you create an Nft item, if the listed is true, It will be listed on the marketplace, so visitors can view it.

function _createNftItem(uint tokenId,uint price) private{
    require(price > 0, "Price must be at least 1 wei");
    _idToNftItem[tokenId]=NftItem(
      tokenId,
      price,
      msg.sender,
      // I set listed true
      true
    );
  }
0

your first tutorial is very similar to openSea.

I guess in the first tutorial and openSea get approval externally from nft owner. because within the contract msg.sender can't call the approval function.

read this for more information: https://github.com/OpenZeppelin/openzeppelin-contracts/issues/4137

Your Answer

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

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