Understanding the Architecture behind NFT Marketplace
This is Mayank, from Thrifty software, again with a new post about the Most hyped product these days, i,e NFT Marketplace. people are crazy about the NFT Marketplace and they want to launch their own for different use cases and themes like Real estate, Art galleries, Gaming, etc.
But When it came to development, it is essential that they know about the Actual design & Architecture behind this Marketplace before they start development. Again like my previous post on developing Custodial Wallet, I won’t be teaching how to develop an NFT marketplace but will be discussing some concepts & Flow behind it.
What is a Non-Fungible Token (NFT)?
NFT stands for non-fungible token. An NFT transforms a digital file ( Image, Audio, gif, Video, PDF) into a digital asset. An NFT token is created and stored on a blockchain, serving as proof of ownership and provenance of a specific item. It works like a digital certificate of authenticity that can be easily verified by anyone anywhere in the world on a blockchain.
Question: Does NFT is only for Artworks (Images, Video, Gifts)?
Answer: Definitely! no NFT for Artworks is just one use case of NFT, but there can be several use cases, like NFT in ticketing, etc.
What is an NFT Marketplace?
NFT marketplace is a marketplace, which allows artists to showcase and list their Artwork in the form of digital tokens( NFT), and buyers/investors can purchase that Artwork. It is very similar to buying & selling products on an eCommerce marketplace like amazon. An Artist can choose various ways of selling their Artwork. They can choose to sell it for a Fixed price, or can put the Artwork in the Auction, open for bidding, where the highest bidder gets to own the NFT.
Different Types of NFT Marketplace
There are basically two types of NFT Marketplaces,
- Primary Marketplace: Primary NFT marketplace is the place, where a creator ( Artist) can mint an NFT token ( Create Artwork in the form of a digital token), and list them for sale.
- Secondary Marketplace: Secondary NFT marketplace is the place, where a collector, who has bought an NFT, can resell, or relist their NFTs.
While the “primary market” refers to the first sale of an artwork, the “secondary market” encompasses all subsequent resales of the work.
In this post, I will be focusing on building a Primary NFT Marketplace.
Understanding the Main Logic Behind the NFT Marketplace
Here are some functions & demonstrations, going through which you will get a complete Idea, of how an NFT marketplace works.
1. Authentication :
Authentication is required, to perform actions in the platform. Although browse functions( Browse NFTs, Browse User, Browse Collection) should be open ( unAuthenticated), but some features like Create Profile, Edit Profile, Like NFT, Create collection, and Delete Collection, need authentication to identify the user.
You can use normal Email / Password or Social Login based Authentication and generate a JWT token, or else if you don’t want to use this Authentication, you can also do using Web3 Wallets like Metamask, Coinbase, etc. Refer to the Article Here.
2. Profiling :
We show the user Profile in the Marketplace, associated with each NFT Card, Leaderboard, Collection, Bidder List, and other places. So we need a maintain the Profile of the user which may include the user’s fullname, username, bio, cover image, avatar & other users’ public information. This information we can keep in our database
3. KYC ( Optional) :
This is Completely Optional. In case you need to build a controlled NFT Marketplace ( Depending on the Legal compliances of your Country), you need to know your customer ( user), for that purpose you need a KYC Module. KYC you can implement in two ways :
- Manual KYC: Either you create your Customer KYC Module, where you collect data from users and verify it from the Admin panel
- 3rd Party API: Or you can use any 3rd Party API like https://onfido.com/ which will do the collection & verification for you.
You can also restrict users from buying/selling in the Platform until the KYC is completed.
4. Create Asset ( Minting) :
Creating a Digital Asset / NFT Artwork on a Marketplace means minting your digital token. Where a user has to upload the Information about the NFT ( Artwork) and mint a new token.
Now, these Include three steps, that are :
- Connecting your DApp with a Web3 Wallet: Minting an NFT on a blockchain, requires you to first connect your Dapp with a web3 wallet like Metamask.
- Uploading Metadata to IPFS: You need to upload your NFT’s Metadata to IPFS ( InterPlanetary File System), metadata includes the NFT’s Assets ( Image, video, GIf), title, description, and Properties. Since we are building a nonfungible token, we need to make sure this metadata stays forever and is decentralized. Thus storing it in IPFS is the best option. If you upload these files in a centralized database, it is risky for the security of your file. After you upload your NFT’s Metadata to IPFS, you will get a metadata ID ( IPFS key)
- Mint your NFT
Take the metadata ID from the IPFS, use it as tokenURI, and sign the transaction, to mint an NFT.
5. List the NFT on Sale :
Once the user has Minted an NFT or purchased (owned) one, they can put the NFT for Sale,
Sale Can be of different Types:
- Fixed Price sale: Here user will list the NFT for a fixed price, so that other users can directly purchase the NFT, by paying the amount given in the NFT detail.
- Auction: Here user will list the NFT for Auction, where the user will specify the minimum Bid Amount and duration of the auction. So users can bid on the NFT. After the Auction is expire, no one will be able to place a bid. Now the Owner can decide to accept/reject the highest bid. In case the user has opted to Accept, The amount will go to the user, and the owner of the NFT will be transferred to the highest bidder.
- Hybrid ( Auction & Fixed Price): User can also List their NFTs, in the hybrid model, i.e List them both for Fixed price & Auction. So here the user has to Specify the minimum Bid Amount, duration of the auction, and buy now price. Now user can place bid on the auction, but if user buy the NFT with Buy now price, the NFT will be immediately sold to the buyer and the auction will be closed.
6. Bidding & Buying :
Users can visit the NFT detail page and can Buy or Bid on an NFT, depending on the form of Sale. ( Buy = Fixed Price or Hybrid, Bid = Auction). The Flow is Almost the same, like :
User Select an NFT → Connect Metamask → Call Buytoken or BidToken function → Sign TX & Send to Blockchain → Event will be triggered which will change the owner in the DB
Any user ( owner) of the NFT, can decide to remove it from Sale ( Fixed Price / Auction). Once it is removed from Sale, no one can purchase it / place a bid
7. Collection & Add NFT to Collection
Collections are used to group the NFTs of similar traits, to make it easy for users to browse. An NFT marketplace should have a feature where users can create/update a collection and assign their NFTs ( they owned) to a collection. Collection can exist on the Database, in order to make it easy for the user to browse/search.
8. Other Views :
Although you have to keep the NFTs metadata in the IPFS, but its good to keep a copy in your Database as well, to improve the query & search functionality in the NFT marketplace. Users will find it convenient to browse the NFT Artwork by searching their title, by category, filter by collection, etc. These could be different views to list the NFTs,
- Trending NFTs
- Browse by Category
- Browse by Collection
- Browse User Profile
- Browse User Created / Owned NFT
After going through the post, you must have got an idea about the Architecture behind an NFT Marketplace, and you must be excited to build your own NFT Marketplace.
You should Refer to Some tutorials & content, that must be useful for you :
In case you are looking for an NFT Marketplace, visit https://thriftysoft.tech/ or feel free to get in touch with us at firstname.lastname@example.org or contact us on Skype. If you just need the UI, shown in the post, buy it here https://codecanyon.net/item/minto-reactjs-nft-marketplace-ui-kit/35888391
We will be happy to help you 😊